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


Java AccountManagerFuture.isDone方法代碼示例

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


在下文中一共展示了AccountManagerFuture.isDone方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: getToken

import android.accounts.AccountManagerFuture; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public String getToken() throws AndroidAuthError {
    AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(mAccount,
            mAuthTokenType, mNotifyAuthFailure, null, null);
    Bundle result;
    try {
        result = future.getResult();
    } catch (Exception e) {
        throw new AndroidAuthError("Error while retrieving auth token", e);
    }
    if (future.isDone() && !future.isCancelled()) {
        if (result.containsKey(AccountManager.KEY_INTENT)) {
            Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
            throw new AndroidAuthError(intent, null);
        }
        authToken = result.getString(AccountManager.KEY_AUTHTOKEN);
    }
    if (authToken == null) {
        throw new AndroidAuthError("Got null auth token for type: " +
                mAuthTokenType);
    }

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

示例8: 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, 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);
    }

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

示例9: getAuthToken

import android.accounts.AccountManagerFuture; //導入方法依賴的package包/類
@SuppressWarnings("deprecation") @Override public String getAuthToken()
        throws AuthFailureError {
    /*
     * 先通過 Account + tokenType
     * 獲取一個 AmsTask<Bundle> ( AccountManagerFuture<Bundle> 的實現類 )
     */
    AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(mAccount, mAuthTokenType,
            mNotifyAuthFailure, null, null);
    Bundle result;
    try {
        // 從 AmsTask<Bundle> 抽出出 Bundle 數據
        result = future.getResult();
    } catch (Exception e) {
        throw new AuthFailureError("Error while retrieving auth token", e);
    }
    String authToken = null;
    // 判斷 AmsTask<Bundle> 是否正常執行
    if (future.isDone() && !future.isCancelled()) {
        if (result.containsKey(AccountManager.KEY_INTENT)) {
            Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
            throw new AuthFailureError(intent);
        }
        // 拿到認證 token 數據
        authToken = result.getString(AccountManager.KEY_AUTHTOKEN);
    }
    if (authToken == null) {
        throw new AuthFailureError("Got null auth token for type: " + mAuthTokenType);
    }

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

示例10: run

import android.accounts.AccountManagerFuture; //導入方法依賴的package包/類
@Override
public void run(AccountManagerFuture<Boolean> future) {
    if (future.isDone()) {
        // after remove account
        Account account = new Account(mAccountName, MainApp.getAccountType());
        if (!AccountUtils.exists(account, MainApp.getAppContext())) {
            // Cancel tranfers
            if (mUploaderBinder != null) {
                mUploaderBinder.cancel(account);
            }
            if (mDownloaderBinder != null) {
                mDownloaderBinder.cancel(account);
            }
        }

        Account a = AccountUtils.getCurrentOwnCloudAccount(this);
        String accountName = "";
        if (a == null) {
            Account[] accounts = AccountManager.get(this)
                    .getAccountsByType(MainApp.getAccountType());
            if (accounts.length != 0)
                accountName = accounts[0].name;
            AccountUtils.setCurrentOwnCloudAccount(this, accountName);
        }
        addAccountsCheckboxPreferences();
    }
}
 
開發者ID:skymania,項目名稱:Cirrus,代碼行數:28,代碼來源:Preferences.java

示例11: 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:himanshuagarwal77225,項目名稱:BookMySkills,代碼行數:33,代碼來源:AndroidAuthenticator.java


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