- 时间:2022-04-27 19:14 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:Android编程实现应用程序开机自启动的方法
本文实例讲述了Android编程实现应用程序开机自启动的方法。分享给大家供大家参考,具体如下:
Android在开机时自动启动一个应用程序
在启动时自动启动一个应用程序:
1、AndroidManifest.xml
<receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
2、permission
[code]<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />[/code]
3、BroadcastReceiver实现
public class BootUpReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
[b]PS:关于AndroidManifest.xml文件相关属性功能可参考本站在线工具:[/b]
[b]Android Manifest功能与权限描述大全:
[/b][url=http://tools.jb51.net/table/AndroidManifest]http://tools.jb51.net/table/AndroidManifest[/url]
更多关于Android相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/410.htm]Android开发入门与进阶教程[/url]》、《[url=http://www.1sucai.cn/Special/375.htm]Android视图View技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/371.htm]Android布局layout技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/508.htm]Android调试技巧与常见问题解决方法汇总[/url]》、《[url=http://www.1sucai.cn/Special/398.htm]Android多媒体操作技巧汇总(音频,视频,录音等)[/url]》、《[url=http://www.1sucai.cn/Special/381.htm]Android基本组件用法总结[/url]》及《[url=http://www.1sucai.cn/Special/124.htm]Android控件用法总结[/url]》
希望本文所述对大家Android程序设计有所帮助。