當前位置: 首頁>>代碼示例>>Java>>正文


Java AccountManagerFuture類代碼示例

本文整理匯總了Java中android.accounts.AccountManagerFuture的典型用法代碼示例。如果您正苦於以下問題:Java AccountManagerFuture類的具體用法?Java AccountManagerFuture怎麽用?Java AccountManagerFuture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AccountManagerFuture類屬於android.accounts包,在下文中一共展示了AccountManagerFuture類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAuthToken

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public String getAuthToken() throws AuthFailureError {
    AccountManagerFuture<Bundle> future = mAccountManager.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);
    }

    return authToken;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:AndroidAuthenticator.java

示例2: getAuthToken

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
public String getAuthToken() throws AuthFailureError {
    AccountManagerFuture<Bundle> future = this.mAccountManager.getAuthToken(this.mAccount, this.mAuthTokenType, this.mNotifyAuthFailure, null, null);
    try {
        Bundle result = (Bundle) future.getResult();
        String authToken = null;
        if (future.isDone() && !future.isCancelled()) {
            if (result.containsKey("intent")) {
                throw new AuthFailureError((Intent) result.getParcelable("intent"));
            }
            authToken = result.getString("authtoken");
        }
        if (authToken != null) {
            return authToken;
        }
        throw new AuthFailureError("Got null auth token for type: " + this.mAuthTokenType);
    } catch (Exception e) {
        throw new AuthFailureError("Error while retrieving auth token", e);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:AndroidAuthenticator.java

示例3: addAccount

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
/**
 * Asks the user to add an account of a specified type.  The authenticator
 * for this account type processes this request with the appropriate user
 * interface.  If the user does elect to create a new account, the account
 * name is returned.
 * <p>
 * <p>This method may be called from any thread, but the returned
 * {@link AccountManagerFuture} must not be used on the main thread.
 * <p>
 *
 */
public AccountManagerFuture<Bundle> addAccount(final int userId, final String accountType,
                                               final String authTokenType, final String[] requiredFeatures,
                                               final Bundle addAccountOptions,
                                               final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
    if (accountType == null) throw new IllegalArgumentException("accountType is null");
    final Bundle optionsIn = new Bundle();
    if (addAccountOptions != null) {
        optionsIn.putAll(addAccountOptions);
    }
    optionsIn.putString(KEY_ANDROID_PACKAGE_NAME, "android");

    return new AmsTask(activity, handler, callback) {
        @Override
        public void doWork() throws RemoteException {
            addAccount(userId, mResponse, accountType, authTokenType,
                    requiredFeatures, activity != null, optionsIn);
        }
    }.start();
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:31,代碼來源:VAccountManager.java

示例4: invalidateAuthToken

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
private void invalidateAuthToken(final Account account, String authTokenType) {
    final AccountManagerFuture<Bundle> future =
            accountManager.getAuthToken(account, authTokenType, null, this, null, null);

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Bundle bnd = future.getResult();

                final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
                accountManager.invalidateAuthToken(account.type, authtoken);
                Log.d("MainActivity", account.name + " invalidated");
            } catch (Exception e) {
                e.printStackTrace();
                showMessage(e.getMessage());
            }
        }
    }).start();
}
 
開發者ID:6thsolution,項目名稱:EasyAppleSyncAdapter,代碼行數:21,代碼來源:MainActivity.java

示例5: getAuthToken

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public String getAuthToken() throws AuthFailureError {
    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);
    }

    return authToken;
}
 
開發者ID:silicon-mountain,項目名稱:smconf-android,代碼行數:27,代碼來源:AndroidAuthenticator.java

示例6: removeAccount

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
private void removeAccount(final Account account) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sharedPreferences.edit().remove("queueName").apply();
    ContentResolver.setIsSyncable(account, WEBINSTALL_SYNC_AUTHORITY, 0);
    ContentResolver.setSyncAutomatically(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, false);
    if(Build.VERSION.SDK_INT>=8){
        ContentResolver.removePeriodicSync(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, new Bundle());
    }
    mAccountManager.removeAccount(account, new AccountManagerCallback<Boolean>() {
        @Override
        public void run(AccountManagerFuture<Boolean> future) {
            addAccount();
            finish();
        }
    }, null);
}
 
開發者ID:Aptoide,項目名稱:aptoide-client,代碼行數:17,代碼來源:MyAccountActivity.java

示例7: addAccount

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
private void addAccount() {
    mAccountManager.addAccount(Aptoide.getConfiguration().getAccountType(), AptoideConfiguration.AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS, null, null, this, new AccountManagerCallback<Bundle>() {
        @Override
        public void run(AccountManagerFuture<Bundle> future) {
            try {
                Bundle bnd = future.getResult();
                if (bnd.containsKey(AccountManager.KEY_AUTHTOKEN)) {
                    setContentView(R.layout.form_logout);
                } else {
                    finish();
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, null);
}
 
開發者ID:Aptoide,項目名稱:aptoide-client,代碼行數:19,代碼來源:MyAccountActivity.java

示例8: addNewAccount

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
private void addNewAccount() {
    mAccountManager.addAccount(EnlightnsAccountAuthenticator.ACCOUNT_TYPE,
            EnlightnsAccountAuthenticator.AUTH_TOKEN_TYPE, null, null, this, new AccountManagerCallback<Bundle>() {
                @Override
                public void run(AccountManagerFuture<Bundle> future) {
                    try {
                        Bundle bnd = future.getResult();
                        showMessage(getString(R.string.successful_login_toast));
                        new GetUserRecordsTask().execute();
                        Log.d(TAG, "AddNewAccount Bundle is " + bnd);
                    } catch (OperationCanceledException oce) {
                        Log.d(TAG, "Operation cancelled, no account available, exiting...", oce);
                        finish();
                    } catch (Exception e) {
                        Log.w(TAG, "Exception", e);
                        showMessage(getString(R.string.login_error));
                    }
                }
            }, null);
}
 
開發者ID:EnlightNS,項目名稱:enlightns-android,代碼行數:21,代碼來源:RecordListing.java

示例9: getAuthToken

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
@Override
public String getAuthToken() throws AuthFailureError {
    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);
    }

    return authToken;
}
 
開發者ID:active-citizen,項目名稱:android.java,代碼行數:26,代碼來源:AndroidAuthenticator.java

示例10: getAuthToken

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
@SuppressWarnings("deprecation") @Override public String getAuthToken()
        throws AuthFailureError {
    AccountManagerFuture<Bundle> future = mAccountManager.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);
    }

    return authToken;
}
 
開發者ID:CaMnter,項目名稱:SaveVolley,代碼行數:25,代碼來源:AndroidAuthenticator.java

示例11: removeAccount

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
/**
 * Remove account from Android system
 */
@SuppressWarnings("deprecation")
public boolean removeAccount() {
    Log.d(getClass().getSimpleName(), "Removing account : " + account.name);

    AccountManager accountManager = AccountManager.get(context);
    // remove account
    AccountManagerFuture accountManagerFuture;
    if(android.os.Build.VERSION.SDK_INT < 23) {
        accountManagerFuture = accountManager.removeAccount(account, null, null);
    } else {
        accountManagerFuture = accountManager.removeAccount(account, null, null, null);
    }
    if (accountManagerFuture.isDone()) {
        try {
            accountManagerFuture.getResult();
            return true;
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "Problem while removing account!", e);
            return false;
        }
    } else {
        return false;
    }
}
 
開發者ID:Kunzisoft,項目名稱:RememBirthday,代碼行數:28,代碼來源:AccountResolver.java

示例12: run

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
@Override
public void run(AccountManagerFuture<Bundle> result) {
    try {
        Log.d(LOGTAG, "OnGMailTokenAcquired::run() begin");
        GMailHandler myHandler = new GMailHandler(getFragmentManager(), ListManager.this);
        Bundle bundle = result.getResult();
        final String oAuth2Token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
        gmailImapReader = new Thread(new GMailImapReader(delayInMillis,
                accounts[getAccountIndex()].name, myHandler, oAuth2Token));
        gmailImapReader.start();
        gmailImapRemover = new Thread(new DeleteEmailViaImap(accounts[getAccountIndex()].name,
                oAuth2Token, emailsToBeRemoved));
        gmailImapRemover.start();
        gmailSmtpWriter = new Thread(new ShareByEmail(accounts[getAccountIndex()].name,
                oAuth2Token, emailsToSend));
        gmailSmtpWriter.start();
        Log.d(LOGTAG, "OnGMailTokenAcquired::run() end");
    } catch (Exception e) {
        Log.d(LOGTAG, "OnTokenAcquired()", e);
    }
}
 
開發者ID:danielebufarini,項目名稱:Reminders,代碼行數:22,代碼來源:ListManager.java

示例13: run

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
@Override
public void run(AccountManagerFuture<Bundle> result) {
	try {
		Bundle bundle;

		bundle = result.getResult();
		Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
		if (intent != null) {
			this.parent.startActivity(intent);
		} else {
			this.auth_token = bundle
					.getString(AccountManager.KEY_AUTHTOKEN);
			this.loginUrl = this.loginUrl + "/_ah/login";
			String request = "?continue="
					+ URLEncoder.encode("nowhere", "UTF-8") + "&auth="
					+ this.auth_token;
			URL url = new URL(this.loginUrl);
			Runnable runnable = new GetCookieRunnable(this.parent, url,
					request, this.localListener);
			new Thread(runnable).start();
		}
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:jcricket,項目名稱:gwt-syncproxy,代碼行數:26,代碼來源:GAEAMCallback.java

示例14: fetchPioneerAccount

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
private void fetchPioneerAccount() {
    String ACCOUNT_TYPE = "com.github.baoti";
    String AUTH_TOKEN_TYPE = "pioneer";

    accountManager.getAuthTokenByFeatures(ACCOUNT_TYPE, AUTH_TOKEN_TYPE, null,
            getView().getActivity(), null, null,
            new AccountManagerCallback<Bundle>() {
                @Override
                public void run(AccountManagerFuture<Bundle> future) {
                    try {
                        Bundle result = future.getResult();
                        String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
                        String type = result.getString(AccountManager.KEY_ACCOUNT_TYPE);
                        String token = result.getString(AccountManager.KEY_AUTHTOKEN);
                        toaster.show(
                                String.format("Auth result - name: %s, type: %s, token: %s",
                                        name, type, token));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, null);
}
 
開發者ID:baoti,項目名稱:Pioneer,代碼行數:24,代碼來源:MainPresenter.java

示例15: run

import android.accounts.AccountManagerFuture; //導入依賴的package包/類
public final void run(AccountManagerFuture<Bundle> paramAccountManagerFuture)
{
  try
  {
    if (this.a.i())
    {
      Intent localIntent = (Intent)((Bundle)paramAccountManagerFuture.getResult()).getParcelable("intent");
      gkl localgkl = this.b;
      bw localbw = this.a.h();
      gko localgko = (gko)localbw.a("new.account.launcher");
      if (localgko == null)
      {
        localgko = new gko();
        localbw.a().a(localgko, "new.account.launcher").c();
      }
      gkn localgkn = new gkn(localgkl, localgko, localIntent);
      efj.m().post(localgkn);
    }
    return;
  }
  catch (Exception localException)
  {
    throw new IllegalStateException(localException);
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:26,代碼來源:gkm.java


注:本文中的android.accounts.AccountManagerFuture類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。