Android 开机自动启动App
来源:互联网 发布:yymodel 数组转模型 编辑:程序博客网 时间:2024/04/19 02:24
/** * Created by zhaomeng on 2017/8/26. * 实现开机可以自动打开软件-----发送广播 */public class BootBroadcastReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { Log.d("XRGPS","BootBroadcastReceiver"+intent.getAction()); System.out.print("开机自启动"); //开机显示的界面 Intent bootIntent=new Intent(context,MainActivity.class); //下面这句话必须加上才能开机自动运行app的界面 bootIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(bootIntent); }}
添加权限和注册广播
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!--配置开机广播--><receiver android:name=".BootBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter></receiver>注:重启手机,测试app有没有自动启动。如果有,那么恭喜你。如果没有,请往下看。
如果按照上面的全部步骤后操作后,重启没有自动启动程序,怎么办呢?是怎么回事呢?那么首先请检查一下你的手机是不是安装了360之类的安全软件,如果有,请在软件的自启动软件管理中将app设置为【允许】(我的手机没有安装这些软件,但是系统设置里面自带了自启动软件管理的功能 ,所以我在这里将我的app设置为【允许开机启动】),重启手机,测试是否成功。如果还是失败,那么请检查你的手机是不是设置了app安装首选位置是sd卡,据说安装到sd卡的话,因为手机启动成功后(发送了启动完成的广播后)才加载sd卡,所以app接收不到广播。如果是的话,把app安装到内部存储试试。如果不懂得设置的话,那么直接在AndroidManifest.xml文件中设置安装路径,android:installLocation="internalOnly"。比如:
<manifest package="cn.weixq.autorun" xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly">
阅读全文
0 0
- 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
- bzoj 2286 虚树
- Java实现发送手机验证码
- 【c++】c++模板类,实现二叉树非递归遍历
- ios面试, 工作葵花宝典之OC最实用的runtime总结
- tensorflow判断两个tensor是否完全相同
- Android 开机自动启动App
- Java线程面试题 Top 50
- 笔试笔记(八)
- 使用Django建站
- No qualifying bean of type [com.jj.mapper.UserMapper] found for dependency
- Coursera机器学习完结
- 一个在线音乐软件的故事(一、故事的由来)
- 【CUGBACM15级BC第26场 A】hdu 5158 Have meal
- CF808B