For licensing purposes, I need to know my users' Android Market account, which I believe is the same as the primary account on their device. I can't find a method that does exactly this so instead I query the user's list of google accounts and use the first one:
AccountManager manager = AccountManager.get(context);
Account[] accounts = manager.getAccountsByType("com.google");
String account = "";
if (accounts != null && accounts.length > 0)
account = accounts[0].name;
return account;
This approach seems to work but my question is: is the first account in the array returned by AccountManager.getAccountsByType("com.google")
guaranteed to always be the same as their Android Market account, or are there any (non-trivial) exceptions?
Thanks in advance...