all.
I am using an account authenticator using AbstractAccountAuthenticator, and I need to call the asynchronous method in the getAuthToken function to authenticate the user. My code is as follows:
public class AccountAuthenticator extends AbstractAccountAuthenticator { ... @Override public Bundle getAuthToken( final AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options ) throws NetworkErrorException { final AccountManager accountManager = AccountManager.get(context); String authToken = accountManager.peekAuthToken( account, authTokenType );
According to Google documentation for the getAuthToken method: it returns a Bundle result or null if the result should be returned via a response . The result will contain:
• AccountManager.KEY_INTENT , or
• AccountManager.KEY_ACCOUNT_NAME , AccountManager.KEY_ACCOUNT_TYPE and AccountManager.KEY_AUTHTOKEN , or
• AccountManager.KEY_ERROR_CODE and AccountManager.KEY_ERROR_MESSAGE to indicate an error
And I need to return null because the authentication method is asynchronous, but how do I return the Bundle via the "response" parameter, as per the documentation?
Thanks to everyone and excuse my English.
source share