Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 6.0 permission.GET_ACCOUNTS

I'm using this to get permission:

if (ContextCompat.checkSelfPermission(context, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {      // Should we show an explanation?     if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.GET_ACCOUNTS)) {      } else {         // No explanation needed, we can request the permission.         ActivityCompat.requestPermissions(context, new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSIONS_REQUEST_GET_ACCOUNTS);          // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an         // app-defined int constant. The callback method gets the         // result of the request.     } } 

But the pop up dialog for permission asks user for access Contacts!?!?

In pre 6.0 in Play Store with

<uses-permission android:name="android.permission.GET_ACCOUNTS"/> 

request is named Identity and explains I need it to get device account.

like image 517
SpyZip Avatar asked Oct 14 '15 12:10

SpyZip


People also ask

What is Get_accounts?

android.permission.GET_ACCOUNTS. Allows access to the list of accounts in the Accounts Service. The app uses this permission in an effort to find the device user's name when the support session is presented to a representative.

What is READ_PHONE_STATE permission?

READ_PHONE_STATE is one of the Android permissions categorized as dangerous. This is because it “allows read only access to phone state, including the phone number of the device, current cellular network information, the status of any ongoing calls, and a list of any Phone Accounts registered on the device” [2] .

What is android permission Request_install_packages?

REQUEST_INSTALL_PACKAGES permission provides apps with the ability to install new packages on a user's device. We are committed to preventing abuse on the Android platform and protecting users from apps that self update using any method other than Google Play's update mechanism or download harmful APKs.

What is android permission Get_tasks?

"GET_TASKS" permission Allows an application to get information about the currently or recently running tasks.


2 Answers

That is because of Permission Groups. Basically, permissions are placed under different groups and all permissions from that group would be granted if one of them is granted.

Eg. Under "Contacts" , there is write/read contacts and get accounts, so when you ask for any of those, the popup asks for Contacts permissions.

Read through: Everything every Android Developer must know about new Android's Runtime Permission


EDIT 1

Just thought i'l add the related(not to get accounts but permissions and groups) Oreo update info:
source: https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp

Prior to Android 8.0 (API level 26), if an app requested a permission at runtime and the permission was granted, the system also incorrectly granted the app the rest of the permissions that belonged to the same permission group, and that were registered in the manifest.

For apps targeting Android 8.0, this behavior has been corrected. The app is granted only the permissions it has explicitly requested. However, once the user grants a permission to the app, all subsequent requests for permissions in that permission group are automatically granted.


like image 69
Pararth Avatar answered Sep 23 '22 20:09

Pararth


GET_ACCOUNTS was moved into the CONTACTS permission group in Android 6.0. While the API has us provide permissions, the user (for Android 6.0 at least) is prompted for permission groups. Hence, the user will be given the same prompt for GET_ACCOUNTS as the user would get for READ_CONTACTS or WRITE_CONTACTS.

like image 39
CommonsWare Avatar answered Sep 21 '22 20:09

CommonsWare