How can I programmatically open the permission screen for a specific app on Android 6.0 (Marshmallow)?

Android M Permission Screen

I have a question regarding the new Android 6.0 (Marshmallow) release. Is it possible to display the "App Permissions" screen for a specific app via an Intent or something similar? It is possible to display the app's "App Info" screen in Settings with the following code:

startActivity( new Intent( android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getPackageName(), null) ) ); 

Is there an analogous solution for directly opening the app's "App Permissions" screen? I already did some research on this but I was not able to find a solution.

31.7k 21 21 gold badges 120 120 silver badges 162 162 bronze badges asked Sep 28, 2015 at 11:40 Frederik Schweiger Frederik Schweiger 8,702 6 6 gold badges 26 26 silver badges 27 27 bronze badges Try this it may be work stackoverflow.com/a/41221852/5488468 Commented Jan 3, 2017 at 10:50 check this Open Application Settings Screen Android Commented May 15, 2019 at 3:40 Take a look stackoverflow.com/questions/47973175/… Commented Apr 12, 2022 at 6:04

15 Answers 15

According to the official Marshmallow permissions video (at the 4m 43s mark), you must open the application Settings page instead (from there it is one click to the Permissions page).

To open the settings page, you would do

Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", getPackageName(), null); intent.setData(uri); startActivity(intent); 
8,462 3 3 gold badges 59 59 silver badges 44 44 bronze badges answered Oct 7, 2015 at 3:06 Martin Konecny Martin Konecny 59.3k 20 20 gold badges 142 142 silver badges 159 159 bronze badges

It is redirecting to general details of Application screen. How can go to specifically App Permissions screen. I don't want that remaining one click too,

Commented Apr 3, 2017 at 6:17 @MilindMevada - you cannot do that at the moment. Commented Apr 3, 2017 at 15:28

could you send data from the settings activity to your activity using intents, in "realtime"? the issue im facing is handling this data in your activity once it got sent from the settings.

Commented Aug 29, 2017 at 6:34

This works when debugging the app, but crashes with no real reason after signing the APK. Nothing obvious in the logcat either.

Commented Jan 29, 2019 at 12:03 Use context.packageName instead of getPackageName() . Commented Dec 6, 2023 at 20:36

This is not possible. I tried to do so, too. I could figure out the package name and the activity which will be started. But in the end you will get a security exception because of a missing permission you can't declare.

Regarding the other answer I also recommend to open the App settings screen. I do this with the following code:

public static void startInstalledAppDetailsActivity(final Activity context) < if (context == null) < return; >final Intent i = new Intent(); i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + context.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(i); > 

As I don't want to have this in my history stack I remove it using intent flags.

val intent = Intent(ACTION_APPLICATION_DETAILS_SETTINGS) with(intent) < data = Uri.fromParts("package", requireContext().packageName, null) addCategory(CATEGORY_DEFAULT) addFlags(FLAG_ACTIVITY_NEW_TASK) addFlags(FLAG_ACTIVITY_NO_HISTORY) addFlags(FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) >startActivity(intent) 
5,446 19 19 gold badges 37 37 silver badges 45 45 bronze badges answered Sep 28, 2015 at 11:50 8,073 3 3 gold badges 31 31 silver badges 39 39 bronze badges I experienced the same and thought there might be a workaround / another solution for this. :-/ Commented Sep 30, 2015 at 17:01

@Mulgard Whatsapp must be using targetSdk="23". This allows the app to to prompt the user to enable the permission. If your target SDK < 23, being able to show the user the app permissions screen is useful, however seems like we can only show the general app settings screen.

Commented Aug 24, 2016 at 23:47

The Intent.FLAG_ACTIVITY_NO_HISTORY may sometimes cause a problemous situation on tablets when a pop-up is shown within the settings screen it will close the settings screen. Simply removing that flag will solve this issue.

Commented Nov 15, 2016 at 11:49

@Thomas R. What is the activity that you said must be started to do so but that was generating the security exception because of the missing permission that can't be declared? I'm curious about that.

Commented Apr 23, 2017 at 21:41

You can show a Toast at the same time instructing the user to go into "Permission" (good idea to localize this message even if rest of your app is not available in the language of the user)

Commented May 7, 2018 at 9:15
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromParts("package", getPackageName(), null); intent.setData(uri); startActivity(intent); 

Description

Settings.ACTION_APPLICATION_DETAILS_SETTINGS
Opens Details setting page for App. From here user have to manually assign desired permission.

Intent.FLAG_ACTIVITY_NEW_TASK
Optional. If set then opens Settings Screen(Activity) as new activity. Otherwise, it will be opened in currently running activity.

Uri.fromParts("package", getPackageName(), null)
Prepares or creates URI, whereas, getPackageName() - returns name of your application package.

intent.setData(uri)
Don't forget to set this. Otherwise, you will get android.content.ActivityNotFoundException . Because you have set your intent as Settings.ACTION_APPLICATION_DETAILS_SETTINGS and android expects some name to search.