获取用户的Andr​​oid Market用户名的最佳方式 [英] Best way to get user's Android Market username

查看:114
本文介绍了获取用户的Andr​​oid Market用户名的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关许可的目的,我需要知道我的用户的Andr​​oid Market帐户,其中的我相信的相同设备上的主帐户。我找不到正是这样做的,而不是让我查询谷歌帐户的用户的列表的方法和使用第一个:

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;

这个方法似乎工作,但我的问题是:是 AccountManager.getAccountsByType返回的数组中的第一个帐户(com.google)保证始终是同他们的Andr​​oid Market帐户,或是否有任何(非平凡)异常?

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?

在此先感谢...

推荐答案

它的使用的是一个手机上注册的第一个com.google帐户是主要的帐户,并采取相应的账户通过Android电子市场使用。

It used to be the case that the first com.google account registered on a phone was the primary account, and accordingly the account used by Android Market.

Android的新版本有一个主帐户的概念废除,和Android Market的新版本还支持多个帐户。

Newer versions of Android have done away with the concept of a primary account, and newer versions of Android Market also support multiple accounts.

总之,不再是一个手机上的账户之间的差额。所有的人都可以同时在使用中由Android市场和应用程式可通过这些账户中的任一项所拥有(以及可能甚至数,如果用户应用程式多次购买)。

In summary, there's no longer any difference between the accounts on a phone. All of them may be in use by Android Market simultaneously, and an app may be owned by any one of those accounts (and possibly even several, if the user has bought the app multiple times).

这篇关于获取用户的Andr​​oid Market用户名的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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