Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getAccountsByType does not return anything in marshmallow

Now this is odd...

Using

AccountManager.newChooseAccountIntent(null, null, new String[] {"com.google"}, null, null, null, null);

does give me a list of accounts. But using

AccountManager.get(context).getAccountsByType("com.google")

returns 0 accounts. The problem only happens in marshmallow.

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

still exists in the manifest.

Any ideas...?

UPDATE: Turns out, must ask permission for GET_ACCOUNTS, even though docs say otherwise... (see comments)

like image 857
rothschild86 Avatar asked Aug 23 '15 00:08

rothschild86


2 Answers

According to this g+ post https://plus.google.com/+BrendonSled/posts/jdrHS3GC7c6 permission GET_ACCOUNTS is now listed as dangerous and user has to allow it

like image 89
Billda Avatar answered Nov 04 '22 02:11

Billda


For anyone getting here, the real answer is here

in short, you need to use AccountManager.newChooseAccountIntent() (ref)

like image 33
Steelight Avatar answered Nov 04 '22 02:11

Steelight