开发者

Getting Android Market Account programmatically

To get the Android Market Account, I do so:

AccountManager accountManager = AccountManager.get(this);
Account[] accounts = accountManager.getAccountsByType("com.google");
androidCheckout = accounts[0].name.trim().toLowerCase();

With my phone and my credentials the above statement is fine. I've an account so masked: "something@gmail.com".

My question is: I know that the accounts can be either Gmail or Google Apps accounts. And also that Google Apps accounts can have any domain n开发者_Python百科ame. So, in this case, instead of @gmail.com there can be everything: depending on the domain name, for instance "cippalippa.us", the account could be "geltrude@cippalippa.us". In this case, the above statement will still be ok??


Account[] accounts = accountManager.getAccountsByType("com.google");

it will work only for google accounts. You can use getAccounts() instead getAccountsByType(), now accounts will be a list of all the sync accounts. You can easily extract your desired account using accounts.name and accounts.type

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜