android设置程序开机自启动

1、自启服务类

 

 1 import android.content.BroadcastReceiver;
 2 import android.content.Context;
 3 import android.content.Intent;
 4 
 5 import com.arcsoft.arcfacedemo.activity.ChooseFunctionActivity;
 6 
 7 /**
 8  * 程序自启动
 9  */
10 public class ContentReceiver extends BroadcastReceiver {
11     @Override
12     public void onReceive(Context context, Intent intent) {
13         Intent it=new Intent(context, ChooseFunctionActivity.class);
14         it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
15         context.startActivity(it);
16     }
17 }

2、在xml里添加服务权限

 1  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 2 
 3 <receiver android:name="com.acmeinte.idl.sample.model.ContentReceiver"
 4              >
 5              <intent-filter>
 6                  <action android:name="android.intent.action.BOOT_COMPLETED"/>
 7                  <category android:name="android.intent.category.LAUNCHER" />
 8                  <category android:name="android.intent.category.HOME" />
 9             </intent-filter>
10          </receiver>

 

3、OK可以开机自启了。

android设置程序开机自启动

上一篇:SUPER DP5 Android Diagnostic Tools Dirgprog5 Dp5 Car Diagnostic


下一篇:关于android8.1实现多个app升级时的注意事项