Android autostart application

前端 未结 1 1214
广开言路
广开言路 2021-01-03 12:50

How can I autostart my application\'s service at device boot (with the possibility of enabling/disabling this feature)? What permissions do I have to include in AndroidManif

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 13:37

    this permission are use

     
    

    In your element (be sure to use a fully-qualified [or relative] class name for your BroadcastReceiver):

      
          
              
          
    
    

    In MyBroadcastReceiver.java:

    package com.example;
    
    public class MyBroadcastreceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            Intent startServiceIntent = new Intent(context, MyService.class);
            context.startService(startServiceIntent);
        }
    }
    



    for more help :: http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/ http://blog.gregfiumara.com/archives/82 http://androidgps.blogspot.com/2008/09/starting-android-service-at-boot-time.html

    0 讨论(0)
提交回复
热议问题