以编程方式获取 Android Market 帐户 [英] Getting Android Market Account programmatically

查看:27
本文介绍了以编程方式获取 Android Market 帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了获得 Android Market 帐户,我这样做:

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();

用我的手机和我的凭据,上面的陈述没问题.我有一个被屏蔽的帐户:something@gmail.com".

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

我的问题是:我知道帐户可以是 Gmail 或 Google Apps 帐户.而且 Google Apps 帐户可以有任何域名.因此,在这种情况下,可以不是@gmail.com,而是一切:根据域名,例如cippalippa.us",帐户可以是geltrude@cippalippa.us".在这种情况下,上面的语句还可以吗??

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 name. 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");

它仅适用于谷歌帐户.您可以使用 getAccounts() 代替 getAccountsByType(),现在 accounts 将是所有同步帐户的列表.您可以使用 accounts.nameaccounts.type

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

这篇关于以编程方式获取 Android Market 帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆