rothschild86 rothschild86 - 12 days ago 5
Android Question

Android 6 Marshmallow: requests for some specific permissions are instantly denied with no ui shown

Using official AVD rev. 3

Calling this:

ActivityCompat.requestPermissions(activity, new String[]{"android.permission.USE_CREDENTIALS"}, REQUEST_PERMISSION_CREDENTIALS);


Fires immediately:

onRequestPermissionsResult (int requestCode, String[] permissions, int[] grantResults)


And resulting code is
PackageManager.PERMISSION_DENIED


Anyone has a fix?

UPDATE:
Known to be affected:

Manifest.permission.CHANGE_NETWORK_STATE
Manifest.permission.WRITE_SETTINGS (solved, see Sam's answer)
android.permission.USE_CREDENTIALS (solved, read Update 2)
READ_SMS


UPDATE 2:
See excellent accepted answer. Essentially, USE_CREDENTIALS is a safe permission now. Beats me why sdk not simply return PERMISSION_GRANTED for it...

Answer

Refer to these pages: permissions by protection level and protection level definitions.

Manifest.permission.CHANGE_NETWORK_STATE

Manifest.permission.WRITE_SETTINGS

These fall under the protection level "signature|appop|pre23|preinstalled" which means that only same-signature apps (system signed basically), app operators, apps that target below API level 23 and presintalled apps can have these.

android.permission.USE_CREDENTIALS

This is only needed on API level 22 and below. See this.

Also you should check out the Behavior Changes.

Comments