Daniel Park
Daniel Park

Reputation: 141

How to open 'App Permissions' page in Settings programmatically in Android?

I know there is many question about it already.
But today I found this:

enter image description here

enter image description here

My phone is Gallaxy Note 4 and Samsung Gallery app works just as I want 'open App permissions page from Activity!' not setting-detail page.

Anyone knows how to do that?

Upvotes: 5

Views: 12534

Answers (1)

Jared Rummler
Jared Rummler

Reputation: 38121

Here is a method to open Settings > Permissions for your application:

public static void openPermissionSettings(Activity activity) {
  Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, 
      Uri.parse("package:" + activity.getPackageName()));
  intent.addCategory(Intent.CATEGORY_DEFAULT);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  activity.startActivity(intent);
}

You should consider using this when your permission is denied and shouldShowRequestPermissionRationale(Activity activity, String permission) returns true.

Upvotes: 8

Related Questions