安卓开机 重启 自启动程序 亲测可用
来源:互联网 发布:印度山地师 知乎 编辑:程序博客网 时间:2024/06/06 07:11
01 添加权限(AndroidManifest.xml文件)
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
02 注册receiver(AndroidManifest.xml文件)
<receiver android:name="com.example.startup.BootBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
03 写receiver
public class BootBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
Thread.sleep(1000);//可要可不要
} catch (InterruptedException e) {
e.printStackTrace();
}
Toast.makeText(context, "接收到信息", 0).show();
Intent ootStartIntent = new Intent(context, MainActivity.class);
ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(ootStartIntent);
}
}
注意事项:
01:模拟器上测试不会成功,不要在模拟器上测试
02:手机端测试安装的时候要勾选程序可自启动,否则测试不会成功
源码地址http://download.csdn.net/detail/yaqiang520/8737317
- 安卓开机 重启 自启动程序 亲测可用
- 安卓开机自启动demo
- 安卓开发实现开机自启动
- 安卓程序 开机启动 后台启动
- 程序开机自启动
- 程序开机自启动
- 程序开机自启动
- 开机自启动程序
- 程序开机自启动
- 程序开机自启动
- 程序开机自启动
- 安卓程序自启动的办法
- android开机自启动与自动重启
- linux软件开机自启动以及定时自动重启
- WinCE程序开机自启动
- Android开机自启动程序
- 开机自启动 BREW 程序
- Android开机自启动程序
- 关于smallest eigenvector的理解
- poj 1077 Eight A*解八数码问题
- DeleteObject()
- LeetCode217:Contains Duplicate
- 第12周项目-阅读程序
- 安卓开机 重启 自启动程序 亲测可用
- 第11周项目2摩托车继承自行车和机动车
- Shell脚本之awk详解
- shell工程代码行数统计
- ios开发必备10款第三方类库
- 2.2.4RemoveDuplicatesfromSortedList
- 视图动画和帧动画
- 图像压缩(SVD方法)
- queue的使用