Anyone knows where is “start in background” permission in MIUI 11?

旧城冷巷雨未停 提交于 2020-01-24 19:05:12

问题


I'm not able to start activity in MIUI 11 redmi note 6 pro mobile, I am getting error as:

com.android.server.am.ExtraActivityManagerService: MIUILOG- Permission Denied Activity

I found some solution like turn on "start in background" permission. I can't find something like this with MIUI 11. Literally I have no idea about this issue. Thanks in advance.


回答1:


I have a similar problem with starting activity from BroadcastReceiver when application is stopped.

1) You can find your app in the settings and allow permission "start in the background".
2) If you need to allow permission programmatically, try to open application settings

Xiaomi

This code will open applicatin permissions settings in which you should allow "start in the background"

Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter",
"com.miui.permcenter.permissions.PermissionsEditorActivity");
intent.putExtra("extra_pkgname", getPackageName());
startActivity(intent);


Devices without system wrappers

This code will open the applicatin settings in which you should open permissions and allow "start in the background" permission

Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Read more about android settings intents: How to open application permission window in app settings programmatically

And you can also check the code from github to work with permissions in different system wrappers like flyme, miui, oppo etc: https://github.com/zhaozepeng/FloatWindowPermission

Hope this helps you!

If you have other options for resolving this issue, I would appreciate a reply in the comments . . .



来源:https://stackoverflow.com/questions/59214359/anyone-knows-where-is-start-in-background-permission-in-miui-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!