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 authenticator's uid
But i didnt get solution.
What is uid? to which uid it comparing.
I am trying
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
}
Error: Caller uid 10782 is different than authenticator's uid .
What it means? how do i correct it?
Any one please tell me how to solve this a complete code will be very helpful.
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?