• 8

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

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

        // 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.

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


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.

  • 35
Reply Report
      • 2
    • write/read storage is NOT under contacts it is under android.permission-group.Storage. Under contacts ther is read/write contacts ofc
      • 2
    • This is the sort of thing that makes me question Google. Contacts is an extremely important permission that protects access to the private info about hundreds of people. GET_ACCOUNTS is almost meaningless in comparison. Now I have to stop using GET_ACCOUNTS in my apps.
      • 2
    • Yeah..i think Google/Android got stuck in between not giving all Permissions before installation and not asking too many permissions individually at runtime. Then it came out to be somewhere in the middle

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.

  • 18
Reply Report

Fortunately this will change in Android N


The GET_ACCOUNTS permission is now deprecated. The system ignores this permission for apps that target Android N.

  • 9
Reply Report

If your using the GET_ACCOUNTS permission to ask the user to select a particular account type on the device(Google in my case), you can use the AccountPicker class which doesn't require any special permissions

Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                    new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE},
                    false, null, null, null, null);
try {
    startActivityForResult(intent, REQUEST_ACCOUNT_PICKER);
} catch (ActivityNotFoundException e) {
    // This device may not have Google Play Services installed.

You'll need Google Play services auth in your gradle dependencies

implementation com.google.android.gms:play-services-auth:16.0.1

This avoids the Contacts permission popup for me

  • 0
Reply Report