AccountManager.addAccountExplicitly returns false on some Android phones

In my application, after entering the system, an account creation section is created, which is usually used to synchronize application data with deleted data.

But if the phone is in a state of instability, it will not create an account, and AccountManager.addAccountExplicitly returns false. But when I check the account [], it returns the length as 1

AccountManager accountManager = AccountManager.get(this); Account[] accounts = accountManager.getAccountsByType("com.sample.account"); if (accounts.length == 0) { addAccountAndSync(); } 

But the application does not appear in the "Accounts" section in the phone settings. Has anyone encountered this situation.

+5
source share
1 answer

This hit on preview N ( https://code.google.com/p/android/issues/detail?id=210466 ). Forcing removeAccount and calling addAccountExplicitly is again a temporary workaround until they fix it.

+2
source

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


All Articles