我的应用程序中有服务需要在设备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" />
期待那些有经验的人的帮助,谢谢!
答案 0 :(得分:0)
尝试添加以下作为组件名称
ComponentName("com.coloros.safecenter", "com.coloros.privacypermissionsentry.PermissionTopActivity")
为OPPO A3设备工作