Android App开机自动启动
来源:互联网 发布:xp如何安装网络打印机 编辑:程序博客网 时间:2024/04/26 11:31
Android App自动启动相关的一搜一大把,刚开始我也是从网上搜了下,不过貌似有些时候有些坑。还有就是在Flyme OS一直不能实现,后来发现是安全中心拦截了,只有白名单上面的App才能开启自启动。实现开机自启动主要是通过BroadcastReceiver接收ACTION_BOOT_COMPLETED的广播来实现的,首先新建一个BroadcastReceiver类:1、启动Activity
Intent bootIntent = new Intent(context, MainActivity.class); bootIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(bootIntent);
2、启动Service
Intent bootIntent = new Intent(context, UploadImageService.class);//为了避免被强制停止后接收不到广播bootIntent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);context.startService(bootIntent);
3、启动整个应用
//包名为要唤醒的应用包名Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage(包名);context.startActivity(bootIntent);
然后要在AndroidManifest里面注册BroadcastReceiver:
<receiver android:name=".receiver.BootReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter></receiver>
最后添加开机启动的权限:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
0 2
- Android App开机自动启动
- android APP开机自动启动
- Android开机自动启动APP
- Android 开机自动启动App
- android开机自动启动Service或app
- Android实现开机自动启动APP
- 开机自动启动app
- Android 开机启动App
- Android开机启动APP
- Android 开机启动app
- android如何实现开机自动启动Service或app
- android如何实现开机自动启动Service或app
- android如何实现开机自动启动Service或app
- android如何实现开机自动启动Service或app(转)
- android如何实现开机自动启动Service或app
- android如何实现开机自动启动Service或app
- android如何实现开机自动启动Service或app
- android如何实现开机自动启动Service或app
- 判断用户登录出错信息
- 使用navicat premium连接oracle数据库的步骤
- linux autotools libtool 生成库版本号设置方法
- 关于http请求body
- 第十周项目四 类的继承教师兼干部类
- Android App开机自动启动
- Android Studio 使用百度移动生态SDK(广告联盟)
- Java文件编码及读写
- 208. Implement Trie (Prefix Tree)字典树
- delphi中多线程排序
- 在ubuntu中安装./install时,提示权限不够怎么办?
- Sublime Text 3的下载安装
- rk3288编译环境
- OS App的性能优化