Android -Starting Service at Boot Time

后端 未结 9 1666
一个人的身影
一个人的身影 2020-11-22 16:12

I need to start a service at boot time. I searched a lot. They are talking about Broadcastreceiver. As I am new to android development, I didn\'t get a clear picture about s

9条回答
  •  抹茶落季
    2020-11-22 16:24

    Your receiver:

    public class MyReceiver extends BroadcastReceiver {   
    
        @Override
        public void onReceive(Context context, Intent intent) {
    
         Intent myIntent = new Intent(context, YourService.class);
         context.startService(myIntent);
    
        }
    }
    

    Your AndroidManifest.xml:

    
    
        
    
            
                
                    
                    
                
            
    
        
            
                
                    
                
            
    
        
    
        
        
    
    
    

提交回复
热议问题