如何在android系统通过AccountManager.addaccountExternally添加谷歌帐户()? [英] How to add google account in android through AccountManager.addaccountExternally()?

查看:1077
本文介绍了如何在android系统通过AccountManager.addaccountExternally添加谷歌帐户()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要明确地添加一个谷歌帐户。我公司将提供的用户名和密码。

I want to add a google account Explicitly. I will provide username and Password.

我刚刚通过本课题<飘一href=\"http://stackoverflow.com/questions/3774282/securityexception-caller-uid-xxxx-is-different-than-the-authenticators-uid\">来电者的uid XXXX比认证的UID 不同
 但是,我没有得到解决。
什么是UID?到UID,还是比较。

I just Gone through this Question caller uid XXXX is different than the authenticator's uid But i didnt get solution. What is uid? to which uid it comparing.

我想

    AccountManager mgr = (AccountManager)getSystemService(ACCOUNT_SERVICE);
    Account acc = new Account("xxxj@gmail.com", "com.google");
    if(mgr.addAccountExplicitly(acc, "Password", new Bundle()))
    {
        //account added successfully
        //do whatever is needed;
        showToast("added");
    }
    else {
        //something did not work
    }

错误:来电UID 10782比认证的uid不同

Error: Caller uid 10782 is different than authenticator's uid .

这意味着什么?如何纠正呢?

What it means? how do i correct it?

中的任何一个,请告诉我如何解决这个问题的完整code会有很大的帮助。

推荐答案

UID 是分配给应用程序的用户ID。每个应用程序有它自己的 UID ,但如果你创建多个应用程序自己有可能使他们的共享同一个 UID

The UID is the user-id assigned to your application. Every application have it's own UID but if you create several applications yourself it is possible to make them share the same UID.

该认证是处理和属于该认证验证账户的模块。因此,谷歌的认证用于处理谷歌的账户和认证X是用来处理X账户。

The authenticator is the module that handles and authenticates accounts that belongs to that authenticator. So Google's authenticator is used for handling Google's accounts and "authenticator X" is used to handle "X accounts".

AddAccountExplicitly 是指用自己的验证器创建自己的类型的帐户时所使用的方法。对文档的 AddAccountExplicitly 说:

AddAccountExplicitly is a method that is meant to be used when creating accounts of your own type with your own authenticator. The documentation for AddAccountExplicitly say:

此方法要求主叫方持有的权限
  AUTHENTICATE_ACCOUNTS并有相同的UID添加的帐户
  认证。

This method requires the caller to hold the permission AUTHENTICATE_ACCOUNTS and to have the same UID as the added account's authenticator.

认证的调用应用程序和 UID UID 的唯一途径可以是相同的是,如果你同时创建调用应用程序和帐户身份验证。

The only way the UID of the calling application and the UID of the authenticator can be the same is if you create both the calling application and the account authenticator.

所以,换句话说,这是不可能添加/使用创建一个谷歌帐户 addAccountExplicitly()。您只能添加帐户为自己服务。

So in other words, it is not possible to add/create a Google account using addAccountExplicitly(). You can only add accounts for your own services.

根据你想要做也许可以显示添加帐户对话框给用户,并让用户添加帐户自理什么:
<一href=\"http://stackoverflow.com/questions/3575303/programatically-starting-the-add-account-activity-in-android-2-2\">Programatically在开始的Andr​​oid 2.2添加帐户活动

Depending on what you want to do maybe you can show the "Add Account" dialog to the user and let the user add an account themself: Programatically starting the 'Add Account' activity in Android 2.2

或者,也许你可以使用Admin SDK目录API创建可与谷歌的服务中使用,但不是一个谷歌帐户,帐户:
我可以以编程方式创建一个谷歌帐户?

Or maybe you could use the Admin SDK's directory API to create accounts that can be used with Google services but that isn't a Google account: Can I create a Google account programmatically?

这篇关于如何在android系统通过AccountManager.addaccountExternally添加谷歌帐户()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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