I have written some code to add my custom account in settings While clicking add account I can see my custom account and when clicking on that I am showing the sign in form. Inside that I am calling the below code
if (mAccountManager.addAccountExplicitly(account, password, userData)) {
        // worked
        System.out.println("Account added");
    } else {
        // guess not
        System.out.println("NOT DONE");
    }
First time it shows "Account added", but cant see anything in Settings/Accounts. PLease anyone help me.
Here is the complete code
Log.d("AuthenticatorActivity", "onCreate");
    mAccountManager = AccountManager.get(getBaseContext());
    String accountName = getIntent().getStringExtra(ARG_ACCOUNT_NAME);
    mAuthTokenType = getIntent().getStringExtra(ARG_AUTH_TYPE);
    if (mAuthTokenType == null)
        mAuthTokenType = AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS;
    accountName= "test55";
    findAccount(accountName);
    System.out.println(mAuthTokenType + "accountName : " + accountName);
    Bundle data = new Bundle();
    data.putString(AccountManager.KEY_ACCOUNT_NAME, accountName);
    data.putString(AccountManager.KEY_ACCOUNT_TYPE, mAuthTokenType);
    data.putString(AccountManager.KEY_AUTHTOKEN, authtoken);
    data.putString(PARAM_USER_PASS, password);
    Bundle userData = new Bundle();
    userData.putString("userObjectId", "2");
    data.putBundle(AccountManager.KEY_USERDATA, userData);
    final Intent res = new Intent();
    res.putExtras(data);
    final Account account = new Account(accountName, "com.coderzheaven.auth_example");
    if (mAccountManager.addAccountExplicitly(account, password, userData)) {
        // worked
        System.out.println("DONE");
    } else {
        // guess not
        System.out.println("NOT DONE");
    }
    mAccountManager.addAccountExplicitly(account, password, userData);
    mAccountManager.setAuthToken(account, mAuthTokenType, authtoken);
    setAccountAuthenticatorResult(data);
    setResult(RESULT_OK, res);
I had the same problem and found that when the android:label field in authenticator.xml (or whatever xml file you are pointing to in your authenticator service definition in AndroidManifest.xml) doesn't contain a localized string that the account does not show up under Settings.
ie, this doesn't work: android:label="My App"
but this does: android:label="@string/my_app"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With