52

Is there an Intent to go to my Application's "App Permissions" screen in Android-M?

I am making my App ready for Android-M and with the new permissions model. I have followed all the steps mentioned in the link

https://developer.android.com/training/permissions/requesting.html

Everything is set and all is good accept that if the user has checked the "Never ask again" button and denied permission, on next launch I want to give the user an option to go to the Application's "App Permissions" and change the permission himself, if he ever changes his mind. I wanted to make it a bit easier for the non-tech savvy user by providing a button which would take the user straight to my application's "App Permissions" screen. Is there a way? (It would be much better than giving the user instructions like MenuSettingsApplicationsManage Applications → select application)

Thank you for helping out!

1

2 Answers 2

95

No, there is no intent to go directly to the Permissions screen.

However, just as in previous versions of Android, you can point people to your application's detail setting page using code such as:

Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
    Uri.fromParts("package", getPackageName(), null));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

This will allow them to only hit a single button (the Permissions button on that screen) before they can access permissions.

Note that as per the UX around asking for permissions, consider linking to the settings page only as a last resort and only in cases where the permission is necessary for your app to function at all - ideally, you should show a strong rationale when shouldShowRequestPermissionRationale() returns true (i.e., they've denied it once but have not hit 'never ask again') such that the second time the user sees a permission dialog they know exactly why you need that permission. This means that users hitting 'never ask again' should be considered a very strong signal that the user will not ever grant you that permission.

6
  • Thanks for the answer. I am displaying adequate wordage explaining why the permission is required as you have suggested and also suggested in the developer.android link. Guess getting to the App's Settings page would be close enough and you are right, if I do not have that permission, the app is pretty much useless so it is my last resort. It's either going to App's Settings and grant permission or bail out of the app at that point. Thanks again Ian! Oct 2, 2015 at 4:00
  • Is it possible to at least go to the global permissions screen? The one that lists all of the permissions, of all apps? Oct 24, 2015 at 8:25
  • It's funny that this should be considered a last resort. I mean, I guess I can understand they want you to use the "official" permission APIs, but the fact that they made the requestPermissions call asynchronous means you cannot implement the M model without almost entirely rearchitecting your app.
    – eidylon
    Jun 17, 2016 at 15:37
  • @eidylon - this also serves as a good opportunity to examine whether you need the dangerous permissions at all - in many cases (such as with the storage permission), alternatives exist. The asynchronous flow is required since your actually starting a new activity when you start the permission dialog, using the same underlying mechanism as startActivityForResult() to request something from another app (in this case, from the system itself). Jun 17, 2016 at 16:19
  • 1
    @eidylon - yeah if you're showing multiple contacts in your UI, then you'd want the Contacts permission. There are a number of common intents for Contacts, but they all revolve around selecting/inserting/editing a particular contact, not viewing them all within your UI. Jun 17, 2016 at 17:06
3

Unfortunately this is not possible, however, as every other app does we can open the app's settings page so the user can grant the necessary permissions manually from there.

val intent = Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null)
)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.