Android: User Id Account (not Id Phone)
I have an app that save the user image but i would save with each image also user id. The user can change telephone device but the google account is always the same. I need a code
Solution 1:
Here is how I do it:
AccountManager accountManager = AccountManager.get(getApplicationContext());
Account[] accounts = accountManager.getAccountsByType("com.google");
for (Account a: accounts) {
if (a.name.contains("@gmail.com")) {
return a.name;
}
}
This will return the first account that ends in @gmail.com; there can be more than one.
Post a Comment for "Android: User Id Account (not Id Phone)"