【发布时间】:2018-04-13 10:21:53
【问题描述】:
我的应用中有服务需要在设备 OPPO 的后台运行。我在某处读到我们需要在应用设置中启用自动启动以保持服务运行,但我的权限有问题。
java.lang.SecurityException: Permission Denial: 从 ProcessRecord{904a19d 12604:elite.driver.adsmove.com.settingpermission/u0a214} 开始 Intent { cmp=com.coloros.safecenter/.startupapp.StartupAppListActivity } ( pid=12604, uid=10214) 需要 oppo.permission.OPPO_COMPONENT_SAFE
当我尝试这样做时
if (Build.MANUFACTURER.equals("OPPO")) {
Intent[] AUTO_START_OPPO = {
new Intent().setComponent(new ComponentName("com.coloros.safe", "com.coloros.safe.permission.startup.StartupAppListActivity")),
new Intent().setComponent(new ComponentName("com.coloros.safe", "com.coloros.safe.permission.startupapp.StartupAppListActivity")),
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startup.StartupAppListActivity"))
};
for (Intent intent : AUTO_START_OPPO) {
if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
try {
startActivity(intent);
break;
} catch (Exception e) {
Log.d(TAG, "OPPO - Exception: "+ e.toString());
}
}
}
}
我也尝试添加权限并请求它但失败了
<!--for OPPO-->
<uses-permission android:name="oppo.permission.OPPO_COMPONENT_SAFE" />
期待有这方面经验的朋友帮忙,谢谢!
【问题讨论】:
-
我希望你已经找到了答案@rameshyogu
-
你找到解决办法了吗?
-
到目前为止,我也没有找到任何解决方案......这真的很令人担忧。
-
你找到解决这个问题的办法了吗?
-
答案在这里:github.com/HOMINHTUNG/Permission-Oppo-Android。 @savvisingh
标签: java android exception permissions oppo