Android.Accounts.AccountManager Class
This class provides access to a centralized registry of the user's online accounts.

See Also: AccountManager Members

Syntax

[Android.Runtime.Register("android/accounts/AccountManager", DoNotGenerateAcw=true)]
public class AccountManager : Java.Lang.Object

Remarks

This class provides access to a centralized registry of the user's online accounts. The user enters credentials (username and password) once per account, granting applications access to online resources with "one-click" approval.

Different online services have different ways of handling accounts and authentication, so the account manager uses pluggable authenticator modules for different account types. Authenticators (which may be written by third parties) handle the actual details of validating account credentials and storing account information. For example, Google, Facebook, and Microsoft Exchange each have their own authenticator.

Many servers support some notion of an authentication token, which can be used to authenticate a request to the server without sending the user's actual password. (Auth tokens are normally created with a separate request which does include the user's credentials.) AccountManager can generate auth tokens for applications, so the application doesn't need to handle passwords directly. Auth tokens are normally reusable and cached by AccountManager, but must be refreshed periodically. It's the responsibility of applications to invalidate auth tokens when they stop working so the AccountManager knows it needs to regenerate them.

Applications accessing a server normally go through these steps:

Some AccountManager methods may need to interact with the user to prompt for credentials, present options, or ask the user to add an account. The caller may choose whether to allow AccountManager to directly launch the necessary user interface and wait for the user, or to return an Intent which the caller may use to launch the interface, or (in some cases) to install a notification which the user can select at any time to launch the interface. To have AccountManager launch the interface directly, the caller must supply the current foreground Android.App.Activity context.

Many AccountManager methods take Android.Accounts.IAccountManagerCallback and Android.OS.Handler as parameters. These methods return immediately and run asynchronously. If a callback is provided then IAccountManagerCallback.run(android.accounts.AccountManagerFuture<V>) will be invoked on the Handler's thread when the request completes, successfully or not. The result is retrieved by calling IAccountManagerFuture.Result on the Android.Accounts.IAccountManagerFuture returned by the method (and also passed to the callback). This method waits for the operation to complete (if necessary) and either returns the result or throws an exception if an error occurred during the operation. To make the request synchronously, call IAccountManagerFuture.Result immediately on receiving the future from the method; no callback need be supplied.

Requests which may block, including IAccountManagerFuture.Result, must never be called on the application's main event thread. These operations throw Java.Lang.IllegalStateException if they are used on the main thread.

[Android Documentation]

Requirements

Namespace: Android.Accounts
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 5