Android APK开机自动运行
来源:互联网 发布:女声变男声软件 编辑:程序博客网 时间:2024/05/30 04:30
Android启动完成后会广播一个action,“android.intent.action.BOOT_COMPLETED”,所以只要APK能够实现接收这个action就可以实现开启自动运行:
实现一个BroadcastReceiver:
public class BootBroadcastReceiver extends BroadcastReceiver {static final String ACTION = "android.intent.action.BOOT_COMPLETED";@Overridepublic void onReceive(Context arg0, Intent arg1) {// TODO Auto-generated method stubif (arg1.getAction().equals(ACTION)) {Intent mMainAcitvityIntent = new Intent (arg0, MainActivity.class);mMainAcitvityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);arg0.startActivity(mMainAcitvityIntent);}}}
AndroidMainifest.xml中:
<receiver android:name="com.himi.edittext.BootBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter></receiver>
注意需要添加权限:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
我在想,Android 的各种action能不能自己定义?比如启动完成后,检查SD卡中有一个文件就广播action A, 启动一个APK;如果没有这个文件就广播action B,启动另一个APK
还要再看看。
- Android APK开机自动运行
- android中APK开机自动运行
- android中APK开机自动运行
- android中APK开机自动运行
- android中APK开机自动运行
- Android---让你的APK程序开机自动运行
- Android开机自动运行
- Android开机自动运行程序
- Android开机自动运行程序
- Android开机自动运行程序
- Android开机自动运行服务
- android 开机自动运行程序
- Android 开机自动运行程序
- 开机自动运行程序【Android】
- Android开机自动运行程序
- android 开机自动运行程序
- android activity/service开机后自动运行
- Android实现开机自动运行程序
- MySql-noinstall实践 2
- java信号灯
- WPF中ListBox的创建和多种绑定用法
- 11g RAC 基本命令管理
- 移动对话框
- Android APK开机自动运行
- Linux(CentOS)挂载移动硬盘,实现文件拷贝、备份
- hdu 2566
- html5新属性 placeholder
- Oracle 行列转换 总结
- flex资料
- 一个漂亮的指令机
- 正则表达式
- C#数据库学习笔记(二)