当前位置: 首页>>代码示例>>Java>>正文


Java AccountManagerFuture.getResult方法代码示例

本文整理汇总了Java中android.accounts.AccountManagerFuture.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java AccountManagerFuture.getResult方法的具体用法?Java AccountManagerFuture.getResult怎么用?Java AccountManagerFuture.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.accounts.AccountManagerFuture的用法示例。


在下文中一共展示了AccountManagerFuture.getResult方法的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: 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: 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

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

示例7: createAccountAndGetToken

import android.accounts.AccountManagerFuture; //导入方法依赖的package包/类
private AndroidToken createAccountAndGetToken(@Nullable Activity activity, @NonNull AndroidTokenType type)
        throws AuthenticatorException, OperationCanceledException, IOException {

    AccountManagerFuture<Bundle> future = accountManager
            .addAccount(type.accountType, type.tokenType, null, null, activity, null, null);
    Bundle result = future.getResult();
    String accountName = result.getString(AccountManager.KEY_ACCOUNT_NAME);
    if (accountName != null) {
        Account account = new Account(result.getString(AccountManager.KEY_ACCOUNT_NAME),
                result.getString(AccountManager.KEY_ACCOUNT_TYPE));
        String token = accountManager.peekAuthToken(account, type.tokenType);
        String refreshToken = accountManager.peekAuthToken(account, getRefreshTokenType(type));
        if (token != null) return new AndroidToken(token, refreshToken);
    }
    return null;
}
 
开发者ID:andretietz,项目名称:retroauth,代码行数:17,代码来源:AndroidTokenStorage.java

示例8: run

import android.accounts.AccountManagerFuture; //导入方法依赖的package包/类
@Override
public void run(AccountManagerFuture<Bundle> bundleAccountManagerFuture) {
    try {
        Bundle result = bundleAccountManagerFuture.getResult();
        Intent intent = (Intent) result.get(AccountManager.KEY_INTENT);
        if (intent == null) {
            String authToken = result.getString(AccountManager.KEY_AUTHTOKEN);
            GutenbergApplication app = GutenbergApplication.from(BaseActivity.this);
            app.setAuthToken(authToken);
            app.requestSync(false);
        } else {
            startActivityForResult(intent, REQUEST_AUTHENTICATE);
        }
    } catch (OperationCanceledException | IOException | AuthenticatorException e) {
        Log.e(TAG, "Error authenticating.", e);
    }
}
 
开发者ID:googlesamples,项目名称:attendee-checkin,代码行数:18,代码来源:BaseActivity.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:goodev,项目名称:android-discourse,代码行数:25,代码来源:AndroidAuthenticator.java

示例10: attemptLogout

import android.accounts.AccountManagerFuture; //导入方法依赖的package包/类
/**
 * Attempts to log out by removing the current Iodine account.
 * This method does not change state on the server.
 * After finishing, this method will call finish() on the passed activity.
 * @param activity The activity used as a context.
 */
public static void attemptLogout(@NonNull final Activity activity) {
    final AccountManager am = AccountManager.get(activity);
    final Account account = getIodineAccount(activity);
    final AccountManagerCallback<Boolean> callback = new AccountManagerCallback<Boolean>() {
        @Override
        public void run(AccountManagerFuture<Boolean> future) {
            try {
                Boolean result = future.getResult();
                if (!result) {
                    throw new Exception("Result is false");
                }
            } catch (Exception e) {
                Log.e(TAG, "Error trying to remove account", e);
                String message = activity.getString(R.string.error_removing_account, e.toString());
                Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
                return;
            }
            Log.i(TAG, "Successfully removed account.");
            Toast.makeText(activity, R.string.sign_out_success, Toast.LENGTH_LONG).show();
        }
    };

    am.removeAccount(account, callback, null);
    activity.finish();
}
 
开发者ID:gengkev,项目名称:thyroxine,代码行数:32,代码来源:IodineAuthUtils.java

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

示例12: updateToken

import android.accounts.AccountManagerFuture; //导入方法依赖的package包/类
private String updateToken(boolean invalidateToken) {
    String authToken = "null";
    try {
        AccountManager am = AccountManager.get(this);
        Account[] accounts = am.getAccountsByType("com.google");
        AccountManagerFuture<Bundle> accountManagerFuture;
        accountManagerFuture = am.getAuthToken(accounts[0], "android", null,this, null, null);
        Bundle authTokenBundle = accountManagerFuture.getResult(10, TimeUnit.SECONDS);
        authToken = authTokenBundle.getString(KEY_AUTHTOKEN);
        if(invalidateToken) {
            am.invalidateAuthToken("com.google", authToken);
            authToken = updateToken(false);
        }
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(this,"Failed requesting AuthToken",Toast.LENGTH_LONG).show();
    }
    return authToken;
}
 
开发者ID:F43nd1r,项目名称:LLXPlaystoreCategories,代码行数:20,代码来源:Parser.java

示例13: run

import android.accounts.AccountManagerFuture; //导入方法依赖的package包/类
@Override
public void run(AccountManagerFuture<Bundle> result) {
	try {
		Bundle bundle = result.getResult();

		Intent launch = (Intent) bundle.get(AccountManager.KEY_INTENT);
		if (launch != null) {
			startActivityForResult(launch, 0);
		} else {
			String token = bundle
					.getString(AccountManager.KEY_AUTHTOKEN);

			authPreferences.setPassword(token);

			startService();
		}
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:nickglobal,项目名称:TvPoo,代码行数:21,代码来源:MainActivity.java

示例14: run

import android.accounts.AccountManagerFuture; //导入方法依赖的package包/类
@Override
public void run(AccountManagerFuture<Bundle> result) {
	try {
		Bundle bundle = result.getResult();

		Intent launch = (Intent) bundle.get(AccountManager.KEY_INTENT);
		if (launch != null) {
			startActivityForResult(launch, AUTHORIZATION_CODE);
		} else {
			String token = bundle
					.getString(AccountManager.KEY_AUTHTOKEN);

			authPreferences.setToken(token);

			doCoolAuthenticatedStuff();
		}
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:TomTasche,项目名称:glassinator,代码行数:21,代码来源:MainActivity.java

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


注:本文中的android.accounts.AccountManagerFuture.getResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。