public class

AccountManager

extends Object
java.lang.Object
   ↳ android.accounts.AccountManager

Class Overview

A class that helps with interactions with the AccountManager Service. It provides methods to allow for account, password, and authtoken management for all accounts on the device. One accesses the AccountManager by calling:

    AccountManager accountManager = AccountManager.get(context);
 

The AccountManager Service provides storage for the accounts known to the system, provides methods to manage them, and allows the registration of authenticators to which operations such as addAccount and getAuthToken are delegated.

Many of the calls take an AccountManagerCallback and Handler as parameters. These calls return immediately but run asynchronously. If a callback is provided then run(AccountManagerFuture) will be invoked wen the request completes, successfully or not. An AccountManagerFuture is returned by these requests and also passed into the callback. The result if retrieved by calling getResult() which either returns the result or throws an exception as appropriate.

The asynchronous request can be made blocking by not providing a callback and instead calling getResult() on the future that is returned. This will cause the running thread to block until the result is returned. Keep in mind that one should not block the main thread in this way. Instead one should either use a callback, thus making the call asynchronous, or make the blocking call on a separate thread.

If one wants to ensure that the callback is invoked from a specific handler then they should pass the handler to the request. This makes it easier to ensure thread-safety by running all of one's logic from a single handler.

Summary

Constants
String ACTION_AUTHENTICATOR_INTENT
String AUTHENTICATOR_ATTRIBUTES_NAME
String AUTHENTICATOR_META_DATA_NAME
int ERROR_CODE_BAD_ARGUMENTS
int ERROR_CODE_BAD_REQUEST
int ERROR_CODE_CANCELED
int ERROR_CODE_INVALID_RESPONSE
int ERROR_CODE_NETWORK_ERROR
int ERROR_CODE_REMOTE_EXCEPTION
int ERROR_CODE_UNSUPPORTED_OPERATION
String KEY_ACCOUNTS
String KEY_ACCOUNT_AUTHENTICATOR_RESPONSE
String KEY_ACCOUNT_MANAGER_RESPONSE
String KEY_ACCOUNT_NAME
String KEY_ACCOUNT_TYPE
String KEY_AUTHENTICATOR_TYPES
String KEY_AUTHTOKEN
String KEY_AUTH_FAILED_MESSAGE
String KEY_AUTH_TOKEN_LABEL
String KEY_BOOLEAN_RESULT
String KEY_ERROR_CODE
String KEY_ERROR_MESSAGE
String KEY_INTENT
String KEY_PASSWORD
String KEY_USERDATA
String LOGIN_ACCOUNTS_CHANGED_ACTION Action sent as a broadcast Intent by the AccountsService when accounts are added to and/or removed from the device's database.
Public Methods
AccountManagerFuture<Bundle> addAccount(String accountType, String authTokenType, String[] requiredFeatures, Bundle addAccountOptions, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
Request that an account be added with the given accountType.
boolean addAccountExplicitly(Account account, String password, Bundle userdata)
Add an account to the AccountManager's set of known accounts.
void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately)
Add a OnAccountsUpdateListener to this instance of the AccountManager.
String blockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure)
Convenience method that makes a blocking call to getAuthToken(Account, String, boolean, AccountManagerCallback, Handler) then extracts and returns the value of KEY_AUTHTOKEN from its result.
void clearPassword(Account account)
Sets the password for account to null.
AccountManagerFuture<Bundle> confirmCredentials(Account account, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
Requests that the authenticator checks that the user knows the credentials for the account.
AccountManagerFuture<Bundle> editProperties(String accountType, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
Request that the properties for an authenticator be updated.
static AccountManager get(Context context)
Retrieve an AccountManager instance that is associated with the context that is passed in.
Account[] getAccounts()
Query the AccountManager Service for all accounts.
Account[] getAccountsByType(String type)
Query the AccountManager for the set of accounts that have a given type.
AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures(String type, String[] features, AccountManagerCallback<Account[]> callback, Handler handler)
AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler)
Request that an authtoken of the specified type be returned for an account.
AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
Request that an authtoken of the specified type be returned for an account.
AccountManagerFuture<Bundle> getAuthTokenByFeatures(String accountType, String authTokenType, String[] features, Activity activityForPrompting, Bundle addAccountOptions, Bundle getAuthTokenOptions, AccountManagerCallback<Bundle> callback, Handler handler)
AuthenticatorDescription[] getAuthenticatorTypes()
Query the AccountManager Service for an array that contains a AuthenticatorDescription for each registered authenticator.
String getPassword(Account account)
Get the password that is associated with the account.
String getUserData(Account account, String key)
Get the user data named by "key" that is associated with the account.
void invalidateAuthToken(String accountType, String authToken)
Removes the given authtoken.
String peekAuthToken(Account account, String authTokenType)
Gets the authtoken named by "authTokenType" for the specified account if it is cached by the AccountManager.
AccountManagerFuture<Boolean> removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler)
Removes the given account.
void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener)
void setAuthToken(Account account, String authTokenType, String authToken)
Sets the authtoken named by "authTokenType" to the value specified by authToken.
void setPassword(Account account, String password)
Sets the password for the account.
void setUserData(Account account, String key, String value)
Sets account's userdata named "key" to the specified value.
AccountManagerFuture<Bundle> updateCredentials(Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
Requests that the authenticator update the the credentials for a user.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_AUTHENTICATOR_INTENT

Since: API Level 5

Constant Value: "android.accounts.AccountAuthenticator"

public static final String AUTHENTICATOR_ATTRIBUTES_NAME

Since: API Level 5

Constant Value: "account-authenticator"

public static final String AUTHENTICATOR_META_DATA_NAME

Since: API Level 5

Constant Value: "android.accounts.AccountAuthenticator"

public static final int ERROR_CODE_BAD_ARGUMENTS

Since: API Level 5

Constant Value: 7 (0x00000007)

public static final int ERROR_CODE_BAD_REQUEST

Since: API Level 5

Constant Value: 8 (0x00000008)

public static final int ERROR_CODE_CANCELED

Since: API Level 5

Constant Value: 4 (0x00000004)

public static final int ERROR_CODE_INVALID_RESPONSE

Since: API Level 5

Constant Value: 5 (0x00000005)

public static final int ERROR_CODE_NETWORK_ERROR

Since: API Level 5

Constant Value: 3 (0x00000003)

public static final int ERROR_CODE_REMOTE_EXCEPTION

Since: API Level 5

Constant Value: 1 (0x00000001)

public static final int ERROR_CODE_UNSUPPORTED_OPERATION

Since: API Level 5

Constant Value: 6 (0x00000006)

public static final String KEY_ACCOUNTS

Since: API Level 5

Constant Value: "accounts"

public static final String KEY_ACCOUNT_AUTHENTICATOR_RESPONSE

Since: API Level 5

Constant Value: "accountAuthenticatorResponse"

public static final String KEY_ACCOUNT_MANAGER_RESPONSE

Since: API Level 5

Constant Value: "accountManagerResponse"

public static final String KEY_ACCOUNT_NAME

Since: API Level 5

Constant Value: "authAccount"

public static final String KEY_ACCOUNT_TYPE

Since: API Level 5

Constant Value: "accountType"

public static final String KEY_AUTHENTICATOR_TYPES

Since: API Level 5

Constant Value: "authenticator_types"

public static final String KEY_AUTHTOKEN

Since: API Level 5

Constant Value: "authtoken"

public static final String KEY_AUTH_FAILED_MESSAGE

Since: API Level 5

Constant Value: "authFailedMessage"

public static final String KEY_AUTH_TOKEN_LABEL

Since: API Level 5

Constant Value: "authTokenLabelKey"

public static final String KEY_BOOLEAN_RESULT

Since: API Level 5

Constant Value: "booleanResult"

public static final String KEY_ERROR_CODE

Since: API Level 5

Constant Value: "errorCode"

public static final String KEY_ERROR_MESSAGE

Since: API Level 5

Constant Value: "errorMessage"

public static final String KEY_INTENT

Since: API Level 5

Constant Value: "intent"

public static final String KEY_PASSWORD

Since: API Level 5

Constant Value: "password"

public static final String KEY_USERDATA

Since: API Level 5

Constant Value: "userdata"

public static final String LOGIN_ACCOUNTS_CHANGED_ACTION

Since: API Level 5

Action sent as a broadcast Intent by the AccountsService when accounts are added to and/or removed from the device's database.

Constant Value: "android.accounts.LOGIN_ACCOUNTS_CHANGED"

Public Methods

public AccountManagerFuture<Bundle> addAccount (String accountType, String authTokenType, String[] requiredFeatures, Bundle addAccountOptions, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)

Since: API Level 5

Request that an account be added with the given accountType. This request is processed by the authenticator for the account type. If no authenticator is registered in the system then AuthenticatorException is thrown.

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
accountType The type of account to add. This must not be null.
authTokenType The account that is added should be able to service this auth token type. This may be null.
requiredFeatures The account that is added should support these features. This array may be null or empty.
addAccountOptions A bundle of authenticator-specific options that is passed on to the authenticator. This may be null.
activity If the authenticator returns a KEY_INTENT in the result then the intent will be started with this activity. If activity is null then the result will be returned as-is.
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns

public boolean addAccountExplicitly (Account account, String password, Bundle userdata)

Since: API Level 5

Add an account to the AccountManager's set of known accounts.

Requires that the caller has permission AUTHENTICATE_ACCOUNTS and is running with the same UID as the Authenticator for the account.

Parameters
account The account to add
password The password to associate with the account. May be null.
userdata A bundle of key/value pairs to set as the account's userdata. May be null.
Returns
  • true if the account was sucessfully added, false otherwise, for example, if the account already exists or if the account is null

public void addOnAccountsUpdatedListener (OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately)

Since: API Level 5

Add a OnAccountsUpdateListener to this instance of the AccountManager. The listener is guaranteed to be invoked on the thread of the Handler that is passed in or the main thread's Handler if handler is null.

You must remove this listener before the context that was used to retrieve this AccountManager instance goes away. This generally means when the Activity or Service you are running is stopped.

Parameters
listener the listener to add
handler the Handler whose thread will be used to invoke the listener. If null the AccountManager context's main thread will be used.
updateImmediately if true then the listener will be invoked as a result of this call.
Throws
IllegalArgumentException if listener is null
IllegalStateException if listener was already added

public String blockingGetAuthToken (Account account, String authTokenType, boolean notifyAuthFailure)

Since: API Level 5

Convenience method that makes a blocking call to getAuthToken(Account, String, boolean, AccountManagerCallback, Handler) then extracts and returns the value of KEY_AUTHTOKEN from its result.

Requires that the caller has permission USE_CREDENTIALS.

Parameters
account the account whose authtoken is to be retrieved, must not be null
authTokenType the type of authtoken to retrieve
notifyAuthFailure if true, cause the AccountManager to put up a "sign-on" notification for the account if no authtoken is cached by the AccountManager and the the authenticator does not have valid credentials to get an authtoken.
Returns
  • an authtoken for the given account and authTokenType, if one is cached by the AccountManager, null otherwise.
Throws
AuthenticatorException if the authenticator is not present, unreachable or returns an invalid response.
OperationCanceledException if the request is canceled for any reason
IOException if the authenticator experiences an IOException while attempting to communicate with its backend server.

public void clearPassword (Account account)

Since: API Level 5

Sets the password for account to null. If the account does not exist then this call has no effect.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
account the account whose password is to be cleared. Must not be null.

public AccountManagerFuture<Bundle> confirmCredentials (Account account, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)

Since: API Level 5

Requests that the authenticator checks that the user knows the credentials for the account. This is typically done by returning an intent to an activity that prompts the user to enter the credentials. This request is processed by the authenticator for the account. If no matching authenticator is registered in the system then AuthenticatorException is thrown.

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
account The account whose credentials are to be checked
options authenticator specific options for the request
activity If the authenticator returns a KEY_INTENT in the result then the intent will be started with this activity. If activity is null then the result will be returned as-is.
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns

public AccountManagerFuture<Bundle> editProperties (String accountType, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)

Since: API Level 5

Request that the properties for an authenticator be updated. This is typically done by returning an intent to an activity that will allow the user to make changes. This request is processed by the authenticator for the account. If no matching authenticator is registered in the system then AuthenticatorException is thrown.

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
accountType The account type of the authenticator whose properties are to be edited.
activity If the authenticator returns a KEY_INTENT in the result then the intent will be started with this activity. If activity is null then the result will be returned as-is.
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns
  • an AccountManagerFuture that represents the future result of the call. The future result is a Bundle that contains either:
    • KEY_INTENT, which is to be used to prompt the user for the credentials
    • nothing, returned if the edit completes successfully
    If the user presses "back" then the request will be canceled.

public static AccountManager get (Context context)

Since: API Level 5

Retrieve an AccountManager instance that is associated with the context that is passed in. Certain calls such as addOnAccountsUpdatedListener(OnAccountsUpdateListener, Handler, boolean) use this context internally, so the caller must take care to use a Context whose lifetime is associated with the listener registration.

Parameters
context The Context to use when necessary
Returns

public Account[] getAccounts ()

Since: API Level 5

Query the AccountManager Service for all accounts.

Returns
  • an array that contains all the accounts known to the AccountManager service. This array will be empty if there are no accounts and will never return null.

    Requires that the caller has permission GET_ACCOUNTS

public Account[] getAccountsByType (String type)

Since: API Level 5

Query the AccountManager for the set of accounts that have a given type. If null is passed as the type than all accounts are returned.

Parameters
type the account type by which to filter, or null to get all accounts
Returns
  • an array that contains the accounts that match the specified type. This array will be empty if no accounts match. It will never return null.

    Requires that the caller has permission GET_ACCOUNTS

public AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures (String type, String[] features, AccountManagerCallback<Account[]> callback, Handler handler)

Since: API Level 5

public AccountManagerFuture<Bundle> getAuthToken (Account account, String authTokenType, boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler)

Since: API Level 5

Request that an authtoken of the specified type be returned for an account. If the Account Manager has a cached authtoken of the requested type then it will service the request itself. Otherwise it will pass the request on to the authenticator. The authenticator can try to service this request with information it already has stored in the AccountManager but may need to launch an activity to prompt the user to enter credentials. If it is able to retrieve the authtoken it will be returned in the result.

If the authenticator needs to prompt the user for credentials it will return an intent for an activity that will do the prompting. If an intent is returned and notifyAuthFailure is true then a notification will be created that launches this intent.

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission USE_CREDENTIALS.

Parameters
account The account whose credentials are to be updated.
authTokenType the auth token to retrieve as part of updating the credentials. May be null.
notifyAuthFailure if true and the authenticator returns a KEY_INTENT in the result then a "sign-on needed" notification will be created that will launch this intent.
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns

public AccountManagerFuture<Bundle> getAuthToken (Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)

Since: API Level 5

Request that an authtoken of the specified type be returned for an account. If the Account Manager has a cached authtoken of the requested type then it will service the request itself. Otherwise it will pass the request on to the authenticator. The authenticator can try to service this request with information it already has stored in the AccountManager but may need to launch an activity to prompt the user to enter credentials. If it is able to retrieve the authtoken it will be returned in the result.

If the authenticator needs to prompt the user for credentials it will return an intent to the activity that will do the prompting. If an activity is supplied then that activity will be used to launch the intent and the result will come from it. Otherwise a result will be returned that contains the intent.

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission USE_CREDENTIALS.

Parameters
account The account whose credentials are to be updated.
authTokenType the auth token to retrieve as part of updating the credentials. May be null.
options authenticator specific options for the request
activity If the authenticator returns a KEY_INTENT in the result then the intent will be started with this activity. If activity is null then the result will be returned as-is.
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns

public AccountManagerFuture<Bundle> getAuthTokenByFeatures (String accountType, String authTokenType, String[] features, Activity activityForPrompting, Bundle addAccountOptions, Bundle getAuthTokenOptions, AccountManagerCallback<Bundle> callback, Handler handler)

Since: API Level 5

Convenience method that combines the functionality of getAccountsByTypeAndFeatures(String, String[], AccountManagerCallback, Handler), getAuthToken(Account, String, Bundle, Activity, AccountManagerCallback, Handler), and addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback, Handler). It first gets the list of accounts that match accountType and the feature set. If there are none then addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback, Handler) is invoked with the authTokenType feature set, and addAccountOptions. If there is exactly one then getAuthToken(Account, String, Bundle, Activity, AccountManagerCallback, Handler) is called with that account. If there are more than one then a chooser activity is launched to prompt the user to select one of them and then the authtoken is retrieved for it,

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
accountType the accountType to query; this must be non-null
authTokenType the type of authtoken to retrieve; this must be non-null
features a filter for the accounts. See getAccountsByTypeAndFeatures(String, String[], AccountManagerCallback, Handler).
activityForPrompting The activity used to start any account management activities that are required to fulfill this request. This may be null.
addAccountOptions authenticator-specific options used if an account needs to be added
getAuthTokenOptions authenticator-specific options passed to getAuthToken
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns

public AuthenticatorDescription[] getAuthenticatorTypes ()

Since: API Level 5

Query the AccountManager Service for an array that contains a AuthenticatorDescription for each registered authenticator.

Returns
  • an array that contains all the authenticators known to the AccountManager service. This array will be empty if there are no authenticators and will never return null.

    No permission is required to make this call.

public String getPassword (Account account)

Since: API Level 5

Get the password that is associated with the account. Returns null if the account does not exist.

Requires that the caller has permission AUTHENTICATE_ACCOUNTS and is running with the same UID as the Authenticator for the account.

public String getUserData (Account account, String key)

Since: API Level 5

Get the user data named by "key" that is associated with the account. Returns null if the account does not exist or if it does not have a value for key.

Requires that the caller has permission AUTHENTICATE_ACCOUNTS and is running with the same UID as the Authenticator for the account.

public void invalidateAuthToken (String accountType, String authToken)

Since: API Level 5

Removes the given authtoken. If this authtoken does not exist for the given account type then this call has no effect.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
accountType the account type of the authtoken to invalidate
authToken the authtoken to invalidate

public String peekAuthToken (Account account, String authTokenType)

Since: API Level 5

Gets the authtoken named by "authTokenType" for the specified account if it is cached by the AccountManager. If no authtoken is cached then null is returned rather than asking the authenticaticor to generate one. If the account or the authtoken do not exist then null is returned.

Requires that the caller has permission AUTHENTICATE_ACCOUNTS and is running with the same UID as the Authenticator for the account.

Parameters
account the account whose authtoken is to be retrieved, must not be null
authTokenType the type of authtoken to retrieve
Returns
  • an authtoken for the given account and authTokenType, if one is cached by the AccountManager, null otherwise.

public AccountManagerFuture<Boolean> removeAccount (Account account, AccountManagerCallback<Boolean> callback, Handler handler)

Since: API Level 5

Removes the given account. If this account does not exist then this call has no effect.

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
account The Account to remove
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns
  • an AccountManagerFuture that represents the future result of the call. The future result is a Boolean that is true if the account is successfully removed or false if the authenticator refuses to remove the account.

public void removeOnAccountsUpdatedListener (OnAccountsUpdateListener listener)

Since: API Level 5
Parameters
listener the listener to remove
Throws
IllegalArgumentException if listener is null
IllegalStateException if listener was not already added

public void setAuthToken (Account account, String authTokenType, String authToken)

Since: API Level 5

Sets the authtoken named by "authTokenType" to the value specified by authToken. If the account does not exist then this call has no effect.

Requires that the caller has permission AUTHENTICATE_ACCOUNTS and is running with the same UID as the Authenticator for the account.

Parameters
account the account whose authtoken is to be set. Must not be null.
authTokenType the type of the authtoken to set. Must not be null.
authToken the authToken to set. May be null.

public void setPassword (Account account, String password)

Since: API Level 5

Sets the password for the account. The password may be null. If the account does not exist then this call has no affect.

Requires that the caller has permission AUTHENTICATE_ACCOUNTS and is running with the same UID as the Authenticator for the account.

Parameters
account the account whose password is to be set. Must not be null.
password the password to set for the account. May be null.

public void setUserData (Account account, String key, String value)

Since: API Level 5

Sets account's userdata named "key" to the specified value. If the account does not exist then this call has no effect.

Requires that the caller has permission AUTHENTICATE_ACCOUNTS and is running with the same UID as the Authenticator for the account.

Parameters
account the account whose userdata is to be set. Must not be null.
key the key of the userdata to set. Must not be null.
value the value to set. May be null.

public AccountManagerFuture<Bundle> updateCredentials (Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)

Since: API Level 5

Requests that the authenticator update the the credentials for a user. This is typically done by returning an intent to an activity that will prompt the user to update the stored credentials for the account. This request is processed by the authenticator for the account. If no matching authenticator is registered in the system then AuthenticatorException is thrown.

This call returns immediately but runs asynchronously and the result is accessed via the AccountManagerFuture that is returned. This future is also passed as the sole parameter to the AccountManagerCallback. If the caller wished to use this method asynchronously then they will generally pass in a callback object that will get invoked with the AccountManagerFuture. If they wish to use it synchronously then they will generally pass null for the callback and instead call getResult() on this method's return value, which will then block until the request completes.

Requires that the caller has permission MANAGE_ACCOUNTS.

Parameters
account The account whose credentials are to be updated.
authTokenType the auth token to retrieve as part of updating the credentials. May be null.
options authenticator specific options for the request
activity If the authenticator returns a KEY_INTENT in the result then the intent will be started with this activity. If activity is null then the result will be returned as-is.
callback A callback to invoke when the request completes. If null then no callback is invoked.
handler The Handler to use to invoke the callback. If null then the main thread's Handler is used.
Returns