How to add google account in android through AccountManager.addaccountExternally()?

前端 未结 1 919
别跟我提以往
别跟我提以往 2021-01-16 21:39

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

I just Gone through this Question caller uid XXXX is different than the authentica

相关标签:
1条回答
  • 2021-01-16 22:22

    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.

    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 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:

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

    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.

    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.

    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

    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?

    0 讨论(0)
提交回复
热议问题