Reputation: 11
I need to create (or associate) a google account on my android device. I have enabled USB-debugging, and I am able to run commands through adb (USB-debugging enabled). I have tried several approaches and searched, but I have not been able to come up with a solution.
I know that you are able to delete a google account with the permission MANAGE_ACCOUNTS, this is one of the reasons why I need to be able to automatically add the account. When simply using addAccountExplicitly with the namespace com.google, it gives me the error "java.lang.SecurityException: caller uid 10165 is different than the authenticator's uid" which is described in the android developer documentation.
Cheers
Upvotes: 1
Views: 1854
Reputation: 926
You can try using the AccountManager addAccount method.
AccountManager accountMgr = AccountManager.get(mContext);
accountMgr.addAccount("com.google", "Auth_Token_Type", null, new Bundle(), (Activity) mContext, null, null);
For the auth token type you may be able to use "oauth2:https://mail.google.com/"
Alternatively, you can use the native device Add Account intent by doing
startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
Upvotes: 1