为什么本人的app在模拟器可以开机自动启动,而在红米手机上不行

Android 码拜 8年前 (2016-03-22) 931次浏览
本人在手机的安全管理里也把应用的权限设置了运行开机自动运行,也还是不行。
下面是本人的实现代码:
1、接收开机广播事件类。
public class BootBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// 接收操作系统启动完成广播,自动启动app
Intent startIntent = new Intent(context, MainActivity.class);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(startIntent);
}
}
2、配置Manifest.xml文件。
<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.HOME”/>
</intent-filter>
</receiver>
解决方案

40

没有权限。假如能随便开机启动,那写一个启动后关机重启然后再开机启动的程序,手机不就报废了嘛

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明为什么本人的app在模拟器可以开机自动启动,而在红米手机上不行
喜欢 (0)
[1034331897@qq.com]
分享 (0)