Android BroadcastReceiver on startup - keep running when Activity is in Background

后端 未结 5 580
眼角桃花
眼角桃花 2020-11-22 05:34

I\'m monitoring incoming SMSs.

My app is working perfectly with a BroadcastReceiver. However it is working from an Activity and would like to keep the <

5条回答
  •  礼貌的吻别
    2020-11-22 05:56

    Add Broadcast Reciever in manifest:

      
            
                
                
            
        
    

    Create Class BootReciever.java

    public class BootReceiver extends BroadcastReceiver {
       @Override
       public void onReceive(Context context, Intent intent) {
           if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
    
               // +++ Do Operation Here +++
    
           }
       }
    }
    

提交回复
热议问题