Android AccountManagerFuture - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AccountManagerFuture class.

This code example shows how to use the following methods:getResult, isCancelled, isDone
        final AccountManager accountManager = AccountManager.get(mContext);
        AccountManagerFuture<Bundle> future = accountManager.getAuthToken(mAccount,
                mAuthTokenType, mNotifyAuthFailure, null, null);
        Bundle result;
        try { 
            result = future.getResult();
        } catch (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)) {
                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: " + mAuthTokenType);
        } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult
			AccountManagerFuture<Bundle> future = am.getAuthToken(acc, type, null, act, null, null);
			 
			Bundle bundle = null;
			 
			try { 
				bundle = future.getResult();
			} catch (OperationCanceledException e) {
			} catch (AuthenticatorException e) {
				AQUtility.debug(e);
			} catch (IOException e) {
				AQUtility.debug(e);
			} 
			 
			return bundle;
		} 
		 
		 
		@Override 
		protected void onPostExecute(Bundle bundle) {
			 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult, isCancelled
    private static AccountManagerCallback<Bundle> getAccountManagerCallback(
            final Activity activity) {
        return new AccountManagerCallback<Bundle>() {
            @Override 
            public void run(AccountManagerFuture<Bundle> future) {
                if (future.isCancelled()) {
                    // The account creation process was canceled 
                    activity.finish();
                    return; 
                } 
                try { 
                    Bundle result = future.getResult();
                    if (result.getBoolean(KEY_USER_SKIPPED_ACCOUNT_SETUP)) {
                        AccountPromptUtils.neverShowAccountPromptAgain(activity);
                    } 
                } catch (OperationCanceledException ignore) {
                    Log.e(TAG, "Account setup error: account creation process canceled");
                } catch (IOException ignore) {
                    Log.e(TAG, "Account setup error: No authenticator was registered for this"
                            + "account type or the authenticator failed to respond"); 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult
            FileActivity.this.mRedirectingToSetupAccount = false;
            boolean accountWasSet = false;
            if (future != null) {
                try { 
                    Bundle result;
                    result = future.getResult();
                    String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
                    String type = result.getString(AccountManager.KEY_ACCOUNT_TYPE);
                    if (AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), name)) {
                        setAccount(new Account(name, type), false);
                        accountWasSet = true;
                    } 
                } catch (OperationCanceledException e) {
                    Log_OC.d(TAG, "Account creation canceled");
                     
                } catch (Exception e) {
                    Log_OC.e(TAG, "Account creation finished in exception: ", e);
                } 
                     
            } else { 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult, isCancelled, isDone
 
    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);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult
 
    private String buildToken(AccountManager manager, Account account, Activity activity)
            throws OperationCanceledException, AuthenticatorException, IOException { 
        AccountManagerFuture<Bundle> future = manager.getAuthToken(account, "ah", null, activity,
                null, null); // ah is app engine 
        Bundle token = future.getResult();
        return token.get(AccountManager.KEY_AUTHTOKEN).toString();
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult, isCancelled, isDone
        final AccountManager accountManager = AccountManager.get(mContext);
        AccountManagerFuture<Bundle> future = accountManager.getAuthToken(mAccount,
                mAuthTokenType, false, null, null);
        Bundle result;
        try { 
            result = future.getResult();
        } catch (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)) {
                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: " + mAuthTokenType);
        } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult, isCancelled, isDone
        final AccountManager accountManager = AccountManager.get(mContext);
        AccountManagerFuture<Bundle> future = accountManager.getAuthToken(mAccount,
                mAuthTokenType, mNotifyAuthFailure, null, null);
        Bundle result;
        try { 
            result = future.getResult();
        } catch (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)) {
                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: " + mAuthTokenType);
        } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult
  private String getNewAuthToken(AccountManager accountManager, Account account) throws 
      OperationCanceledException, IOException, AuthenticatorException { 
    AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthToken(account, "ah", 
        null, context, null, null);
 
    Bundle authTokenBundle = accountManagerFuture.getResult();
    return authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString();
  } 
 
  private Account getGoogleAccount(AccountManager accountManager, String desiredSuffix) {
    for (Account account : accountManager.getAccountsByType(GOOGLE_ACCOUNT_TYPE)) {
      if (account.name.endsWith(desiredSuffix)) {
        return account;
      } 
    } 
    return null; 
  } 
   
  /** 
   * Creates a GoogleAccountLoginHelper that will return authorization in a state you like. 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getResult
    private PendingIntent mPendingIntent;
 
    private AccountManagerCallback<Bundle> mCallback = new AccountManagerCallback<Bundle>() {
        public void run(AccountManagerFuture<Bundle> future) { 
            try { 
                Bundle bundle = future.getResult(); 
                bundle.keySet(); 
                setResult(RESULT_OK); 
 
                if (mPendingIntent != null) { 
                    mPendingIntent.cancel(); 
                } 
 
                if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "account added: " + bundle); 
            } catch (OperationCanceledException e) { 
                if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "addAccount was canceled"); 
            } catch (IOException e) { 
                if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "addAccount failed: " + e); 
            } catch (AuthenticatorException e) { 
                if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "addAccount failed: " + e); 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Android AccountManagerFuture Methods: