AccountManager adds an account but does not appear in the "Accounts in Settings" section

I created my own account type by running the SimpleSyncAdapter example provided by android. I can add accounts to the Account Manager and on some phones (tested on Galaxy S3, Galaxy Nexus, HTC Desire HD), I see my account in the “Accounts and sync in settings” section. To add an account, I do the following:

boolean added = mAccountManager.addAccountExplicitly(account, password, null); 

However, in Galaxy Note 2 and Motorola Xoom, even if this returns true, the account does not appear under the account and sync.

Has anyone seen this problem before?

+4
source share
2 answers

I am missing a call to setAccountAuthenticatorResult.

 boolean added = mAccountManager.addAccountExplicitly(account, password, new Bundle()); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, username); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); 
+1
source

I came across this question because I had the same problem on the emulator. I could access account data through the AccountManager, but did not appear in the accounts and synchronization. I finally restarted the emulator with the verified "Wipe user data" and the problem disappeared.

I do not know how to simulate this process on your devices, but perhaps deleting the specified account using AccountManager.removeAccount (...) will clear some outdated account data and allow you to reset the Account. There is clearly a gap between account information, AccountManager and SyncAdapter configurations, and having an account in accounts and synchronization. I just don’t understand where it is.

I hope this helps a more knowledgeable contributor to answer the original question more fully.

0
source

Source: https://habr.com/ru/post/1468823/


All Articles