Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 获取用户';s安卓市场用户名_Android_Google Play - Fatal编程技术网

Android 获取用户';s安卓市场用户名

Android 获取用户';s安卓市场用户名,android,google-play,Android,Google Play,出于授权目的,我需要知道我用户的Android Market帐户,我相信这与他们设备上的主帐户相同。我找不到一种方法可以做到这一点,因此我查询用户的google帐户列表,并使用第一个: AccountManager manager = AccountManager.get(context); Account[] accounts = manager.getAccountsByType("com.google"); String account = ""; if

出于授权目的,我需要知道我用户的Android Market帐户,我相信这与他们设备上的主帐户相同。我找不到一种方法可以做到这一点,因此我查询用户的google帐户列表,并使用第一个:

    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”)
返回的数组中的第一个帐户是否保证始终与他们的Android Market帐户相同,或者是否存在任何(非平凡的)异常

提前感谢…

过去,手机上注册的第一个com.google帐户是主要帐户,因此Android Market使用的帐户

较新版本的Android已经取消了主帐户的概念,而较新版本的Android Market也支持多个帐户


总之,手机上的账户之间不再有任何区别。Android Market可能同时使用所有这些帐户,并且一个应用程序可能属于其中任何一个帐户(如果用户多次购买该应用程序,则可能是多个帐户)。

用户仍可以更改其主要电子邮件,登录安卓Market,因此,使用market帐户进行许可并没有那么有效。我也不认为有一种实际的方法来确认是否有一个帐户是主要的。更改主要帐户的唯一方法是擦除设备,所以我不担心这一点。我的许可需要合理的安全,但我知道没有一种方法是完美的。我遇到了同样的问题,你想出了解决方案吗?我只需要一个uid,可以是他们的市场帐户电子邮件,但不知道如何强制执行。对不起,没有,我没有找到更好的解决方案。你知道什么版本吗?谢谢。这是在蜂巢(Android 3.0)中更改的。