When I see that the user does not have accounts in the account manager, I try to do the following to send the user to the account settings action and create an account for him.
AccountManagerFuture<Bundle> addAccount = accountManager.addAccount(ACCOUNT_TYPE, TOKEN, null, null, MyActivity.this, // activity null, // callback null); // handler Intent result = (Intent) addAccount.getResult().get(AccountManager.KEY_INTENT); startActivity(result);
This throws a IllegalStateException , calling it from the main thread, can lead to a deadlock. What is the best way to perform this type of operation, and does anyone have a good example of code in action?
android accountmanager
Abdullah jibaly
source share