Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem using android.accounts Authenticator
    primarykey
    data
    text
    <p>I'm new to the android.accounts apis, and now I'm trying to do something with them but a seemly dummy problem occurs...<br> I`ve created an Authenticator for my app but did not yet implement the abstract methods. The icon of it successfully appears in the system Add a Account window, and I know that when I click it, the method addAccount in the Authenticator will be invoked. </p> <p>Now I wish to do some simple thing in this method, and write codes below: </p> <pre><code> @Override public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) { Log.d(LOG_TAG, "RRAuthenticator add account... "); String accountName = "example@example.com"; Account account = new Account(accountName, accountType); String password = "example_password"; AccountManager manager = AccountManager.get(context); manager.addAccountExplicitly(account, password, null); Bundle bundle = new Bundle(); bundle.putString(AccountManager.KEY_ACCOUNT_NAME, accountName); bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType); bundle.putString(AccountManager.KEY_AUTHTOKEN, "example_authtoken"); return bundle; } </code></pre> <p>I've seen the demo of SampleSyncAdapter, and make moves like it. But I practice using these APIs by directly adding an account. But system crashed by the line <code>manager.addAccountExplicitly(account, password, null);</code> What's wrong with it?</p> <hr> <p>Added later: Exception in system process. System will crash. NullPointerException throw by AccountManager. It seems the problem of the addAccountExplicitly method, as I comment this statement no crash happen.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload