0

Is there any way to retrieve current google play logged user on an android device?

I want to make an application that takes this username or userid from android and send it to one of my servers and like this authentificate the user on my service.

I know there are multiple ways to auth trough facebook, twitter, google and many other providers, but i want to make it work without asking username and password.

Thanks

IceDevil
  • 154
  • 1
  • 9

1 Answers1

0

Yes, but you have you add a premission request in the manfiest

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

Then you can use the folloing method to get an array of all the account configured on the device:

Account[] accounts = ((AccountManager) getSystemService(ACCOUNT_SERVICE)).getAccounts();
Kirill Kulakov
  • 10,035
  • 9
  • 50
  • 67
  • what if the user has configured 2 google accounts? let's say he's using 1 for google play and another just for email. How do i know which one to pick. Also it seems like account manager regenerates the token, how can i validate the token on my server side? :| – IceDevil Mar 16 '13 at 16:24
  • Check this out http://stackoverflow.com/questions/2720315/what-should-i-use-android-accountmanager-for – Kirill Kulakov Mar 16 '13 at 16:28