Code example for AccountManagerFuture

Methods: getResultisCancelledisDone

0
 
    final AccountManager accountManager = AccountManager.get(this.mContext);
    final AccountManagerFuture<Bundle> future = accountManager.getAuthToken(this.mAccount, this.mAuthTokenType, this.mNotifyAuthFailure, null, null);
    Bundle result;
    try { 
      result = future.getResult();
    } 
    catch (final Exception e) {
      throw new AuthFailureError("Error while retrieving auth token", e);
    } 
    String authToken = null;
    if (future.isDone() && !future.isCancelled()) {
      if (result.containsKey(AccountManager.KEY_INTENT)) {
        final Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
        throw new AuthFailureError(intent);
      } 
      authToken = result.getString(AccountManager.KEY_AUTHTOKEN);
    } 
    if (authToken == null) {
      throw new AuthFailureError("Got null auth token for type: " + this.mAuthTokenType);
Experience pair programming with AI  Get Codota for Java