Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

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?

like image 271
Daniel Park Avatar asked Mar 13 '23 09:03

Daniel Park


1 Answers

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.

like image 116
Jared Rummler Avatar answered Apr 26 '23 07:04

Jared Rummler