How to use getApplicationContext in BroadcastReceiver class?

前端 未结 3 1264
醉话见心
醉话见心 2021-01-11 19:22

I am using the broadcaster class to listen to sms messages using this code

package com.escortme.basic;

import android.content.BroadcastReceiver;
import and         


        
3条回答
  •  耶瑟儿~
    2021-01-11 19:28

    One reason for getting the application context would be to get the the WIFI_SERVICE as it must be looked up on the Application context or memory will leak on devices < Android N.

    As Someone Somewhere once said, within onReceive(), just use context.getApplicationContext().

提交回复
热议问题