How to get google user account?

How can I get the user market account, the account with which they install applications on the Google market, from the code?

+4
source share
2 answers

If you searched for a Configured Device Email ID, this will help you.

Account[] accounts = AccountManager.get(ContactUs.this).getAccounts(); for (Account account : accounts) { // TODO: Check possibleEmail against an email regex or treat // account.name as an email address only for certain account.type values. String possibleEmail = account.name; Log.i("Email ID",possibleEmail); } 
0
source

However, you are trying to get only google accounts like this:

 Account[] accounts = AccountManager.get(this).getAccountsByType("com.google"); for (Account account : accounts) { // this is where the email should be in: String email = account.name; } 
+2
source

Source: https://habr.com/ru/post/1392661/


All Articles