Android -Starting Service at Boot Time

后端 未结 9 1765
一个人的身影
一个人的身影 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:37

    Also register your created service in the Manifest and uses-permission as

    
       
            
                
            
       
    
    
    

    and then in braod cast Reciever call your service

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

提交回复
热议问题