Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a question regarding the new Android 6.0 (Marshmallow) release:

Is it achievable to display the permission screen for a specific app via an Intent or something similar?

Android M Permission Screen

It's possible to display the app settings with the following code - is there an analog solution for directly opening the permission screen?

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

I already did some research on this, but I wasn't able to find a proper solution.

like image 643
Frederik Schweiger Avatar asked Sep 28 '15 11:09

Frederik Schweiger


People also ask

How do I set permissions in android programmatically?

You need to declare the permissions in the manifest file first before you request for them programmatically. refer this for more information. declaring the permission in the manifest file is static type declaration by which your os know what kind of permission your app might require.

Can Android developer set custom permissions to apps?

Apps can define their own custom permissions and request custom permissions from other apps by defining <uses-permission> elements. However, you should carefully assess whether it is necessary for your app to do so.

How do I set custom permissions on Android?

Android allows you to define custom permissions with your application. For example, if you wanted to prevent certain users from starting one of the activities in your application, you could do that by defining a custom permission. To use custom permissions, you first declare them in your AndroidManifest. xml file.


1 Answers

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); 
like image 50
14 revs, 12 users 16% Avatar answered Oct 06 '22 06:10

14 revs, 12 users 16%