Android开机自启
16lz
2021-01-23
public class BootReceiver extends BroadcastReceiver { @Override
public void onReceive(Context ctx, Intent intent) {
Log.i("BootReceiver__onReceive","onReceive");
String action="android.intent.action.MAIN";
String category="android.intent.category.LAUNCHER";
Intent myi=new Intent(ctx,IndexActivity.class);//跳转到应用的入口页面
myi.setAction(action);
myi.addCategory(category);
myi.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(myi); }
}
public void onReceive(Context ctx, Intent intent) {
Log.i("BootReceiver__onReceive","onReceive");
String action="android.intent.action.MAIN";
String category="android.intent.category.LAUNCHER";
Intent myi=new Intent(ctx,IndexActivity.class);//跳转到应用的入口页面
myi.setAction(action);
myi.addCategory(category);
myi.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(myi); }
}
在配置文件中添加权限:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
在配置文件中添加:
<receiver android:name=".BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
更多相关文章
- Android 应用获取通知栏权限
- Android的权限机制之—— “沙箱”机制sharedUserId跟签名
- Android Manifest.permission权限
- Android 系统下模拟触点击的功能与权限
- android 笔记 --- Android各种访问权限Permission详解
- Android 操作权限大全(已归纳分类)
- Android root权限获取大揭秘
- Android开发录音和播放音频的步骤(动态获取权限)
- Android权限【大全】
随机推荐
- Android(安卓)Build: Tips and Tricks
- How to start a new process for Android
- android p vts VtsTrebleVendorVintfTest
- Android(安卓)Studio build.gradle 编码
- Android(安卓)Neon 优化方式讲解
- 最近在翻译国外一本新书 The Android(安
- Android:从Eclipse到Android(安卓)Studio
- android 在google商店里搜索不到的问题
- android 计算器(2)
- android studio 程序员有福了—从layout