2

Is there a way to redirect a user to the settings of an application or better to the permissions of a specific application? as shown below:

enter image description here

enter image description here

Best regards.

FeleMed
  • 601
  • 9
  • 28

2 Answers2

11

There is no intent to go directly to permissions page.

However, there is an intent by which you can redirect your user to your Application's detailed settings page. ACTION_APPLICATION_DETAILS_SETTINGS

Here is the code snippet:

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);

I hope this helps!

Naveen T P
  • 6,955
  • 2
  • 22
  • 29
  • the context it is undefined so it is the activity what do I need to write there for both of them ? I tried `getApplicationContext().startActivity` but it is throwing me error. – TheCoderGuy Mar 06 '19 at 10:45
  • This is creating runtime exception android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. so we need to set the flag for the intent ```intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);``` – Baskar PC Dec 21 '22 at 13:17
5

Is there a way to redirect a user to the settings of an application

Use ACTION_APPLICATION_DETAILS_SETTINGS.

or better to the permissions of a specific application?

I do not think that there is a way to drive to that specific screen.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I'm getting a crash: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.APPLICATION_DETAILS_SETTINGS } – FeleMed Jan 12 '16 at 22:07
  • 1
    @FeleMed: As the documentation states, "In some cases, a matching Activity may not exist, so ensure you safeguard against this." Beyond that, you need to put a `Uri` on the `Intent`, one with a `package` scheme that points to your app. See http://stackoverflow.com/a/32983128/115145. – CommonsWare Jan 12 '16 at 22:17
  • ACTION_APPLICATION_DETAILS_SETTINGS worked, thanks. On the second question, here: https://www.youtube.com/watch?v=f17qe9vZ8RM at around 27:30 the speaker said that if your permissions haven't been denied before you can intent directly to the app permissions, can't find the documentation though. – FeleMed Jan 12 '16 at 22:33
  • @FeleMed: I don't see anything undocumented in [the current Settings app's manifest](https://android.googlesource.com/platform/packages/apps/Settings/+/master/AndroidManifest.xml) that fits the bill, but, then again, there are a million references to "permission" in there... :-) – CommonsWare Jan 12 '16 at 22:36