Android开机自动启动程序
来源:互联网 发布:事业单位粉笔软件 编辑:程序博客网 时间:2024/05/16 04:55
1.定义一个BroadcastReceiver
- public class BootReceiver extends BroadcastReceiver {
- public void onReceive(Context ctx, Intent intent) {
- Log.d("BootReceiver", "system boot completed");
- //start activity
- String action="android.intent.action.MAIN";
- String category="android.intent.category.LAUNCHER";
- Intent myi=new Intent(ctx,CustomDialog.class);
- myi.setAction(action);
- myi.addCategory(category);
- myi.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- ctx.startActivity(myi);
- //start service
- Intent s=new Intent(ctx,MyService.class);
- ctx.startService(s);
- }
- }
- public class BootReceiver extends BroadcastReceiver {
- public void onReceive(Context ctx, Intent intent) {
- Log.d("BootReceiver", "system boot completed");
- //start activity
- String action="android.intent.action.MAIN";
- String category="android.intent.category.LAUNCHER";
- Intent myi=new Intent(ctx,CustomDialog.class);
- myi.setAction(action);
- myi.addCategory(category);
- myi.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- ctx.startActivity(myi);
- //start service
- Intent s=new Intent(ctx,MyService.class);
- ctx.startService(s);
- }
- }
2.配置Receiver的许可,允许接收系统启动消息,在AndroidManifest.xml中:
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
3.配置Receiver,可以接收系统启动消息,在AndroidManifest.xml中
- <receiver android:name=".app.BootReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED"/>
- <category android:name="android.intent.category.HOME" />
- </intent-filter>
- </receiver>
- <receiver android:name=".app.BootReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED"/>
- <category android:name="android.intent.category.HOME" />
- </intent-filter>
- </receiver>
0 0
- android程序开机自动启动
- Android开机自动启动程序
- android开机自动启动程序
- android 开机自动启动程序
- Android开机自动启动程序设置
- Android手机开发:开机自动启动程序
- Android开机自动启动程序设置 .
- Android 开机自动启动程序详解
- 程序开机自动启动
- 开机自动启动程序
- 开机自动启动程序
- 开机自动启动程序
- 开机自动启动程序
- 开机自动启动程序
- 开机自动启动程序
- android开机自动启动
- android 开机自动启动
- android 开机自动启动
- c++ 单词转换 map对象
- 升级 Mellanox ConnectX-3 EN 10/40 Gbps 网卡固件
- Android 消息处理源码分析(1)
- 共享内存是最快的一种IPC方式
- asp .net 获取当前url各种属性
- Android开机自动启动程序
- Hibernate复合主键(注解)操作分区数据表
- linux 流量统计小程序
- css实现tip popup
- 虚拟机3种网络模式(桥接、nat、Host-only)
- 常用命令总结
- 2012年5月SAT香港真题解析
- iOS手势 清扫和长按和旋转
- AnimationDrawable的使用