The Android Account Authenticator system can be used to make the client authenticate with a remote server. Three pieces of information are required:
A service, triggered by the android.accounts.AccountAuthenticator. Its onBind method should return a subclass of AbstractAccountAuthenticator.
An activity to prompt the user for credentials (Login activity)
An xml resource file to describe the account
1. The service:
Place the following permissions in your AndroidManifest.xml:
Declare the service in the manifest file:
Note that the android.accounts.AccountAuthenticator is included within the intent-filter tag. The xml resource (named authenticator here) is specified in the meta-data tag.
The service class:
2. The xml resource:
Do not directly assign a string to android:label or assign missing drawables. It will crash without warning.
3. Extend the AbstractAccountAuthenticator class:
The addAccount() method in AbstractAccountAuthenticator class is important as this method is called when adding an account from the "Add Account" screen in under settings. AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE is important, as it will include the AccountAuthenticatorResponse object that is needed to return the account keys upon successful user verification.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0