I am trying to use AccountManager to get a token for an installed Google account. When I call getResult () on my AccountManagerFuture object, I get a βCannot log inβ screen on the device (which further says: βAn error has occurred with Google servers. Please try again later.) I checked that a network connection is available before calling this method I also checked on a device that I can access, for example google.com, in the browser. Here is the code for my AccountManagerCallback:
amf = accMgr.getAuthToken(account, authTokenType, null, true, new AccountManagerCallback<Bundle>() { public void run(AccountManagerFuture<Bundle> arg0) { Bundle result; Intent i; String token; try { result = arg0.getResult(); if (result.containsKey(AccountManager.KEY_INTENT)) { i = (Intent)result.get(AccountManager.KEY_INTENT); if (i.toString().contains("GrantCredentialsPermissionActivity")) {
In addition, these entries in LogCat may be useful:
08-02 15:51:00.911: I/GLSUser(10134): GLS error: Unknown XXXX@gmail.com com.google 08-02 15:51:00.911: V/GoogleLoginService(10134): Returning error intent with: ComponentInfo{com.google.android.gsf.login/com.google.android.gsf.login.LoginActivity} 08-02 15:51:03.294: I/ActivityManager(324): START {cat=[XXXX@gmail.com] flg=0x10000000 cmp=com.google.android.gsf.login/.LoginActivity (has extras) u=0} from pid 11147
(Note: The actual gmail account name has been removed to avoid spam.)
java android accountmanager
robguinness
source share