How to open application permission window in app settings programmatically [duplicate]

早过忘川 提交于 2019-11-29 15:57:31

问题


This question already has an answer here:

  • How to programmatically open the Permission Screen for a specific app on Android Marshmallow? 10 answers

I'm working on new permission model (Android 6.0 Marshmallow) and I wonder is there a way to open the application's permission window programmatically?

not only application details

I managed to open the second screen using something like this

private void goToSettings() {
    Intent myAppSettings = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + getPackageName()));
    myAppSettings.addCategory(Intent.CATEGORY_DEFAULT);
    myAppSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(myAppSettings);
}

But I have no idea how to open the first one.

Your help will be much appreciated :)


回答1:


This is not possible. You can open the App settings screen but not the permissions setting screen.

Refer to this question for more explanations.

Here I am sharing code to open application setting screen,

Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
intent.setData(uri);
context.startActivity(intent);

For more you can refer Open Application Settings Screen Android



来源:https://stackoverflow.com/questions/35456767/how-to-open-application-permission-window-in-app-settings-programmatically

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