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


Java AccountUtils.setActiveAccount方法代码示例

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


在下文中一共展示了AccountUtils.setActiveAccount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Handle the select {@code startActivityForResult} from
    // {@code enforceActiveGoogleAccount()} when a Google Account wasn't present on the device.
    if (requestCode == SELECT_GOOGLE_ACCOUNT_RESULT) {
        if (resultCode == RESULT_OK) {
            // Set selected GoogleAccount as active.
            String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            AccountUtils.setActiveAccount(this, accountName);
            onAuthSuccess(accountName, true);
        } else {
            LOGW(TAG, "A Google Account is required to use this application.");
            // This application requires a Google Account to be selected.
            finish();
        }
        return;
    }

    if (mLoginAndAuthHelper == null || !mLoginAndAuthHelper.onActivityResult(requestCode,
            resultCode, data)) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:24,代码来源:BaseActivity.java

示例2: setFirstAvailableAccountAsActive

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
 *
 * @return account name, or a test account name
 */
public static String setFirstAvailableAccountAsActive(Context context) {
    String account;
    AccountManager am =
            AccountManager.get(InstrumentationRegistry.getTargetContext());
    Account[] accountArray =
            am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    if (accountArray.length > 0) {
        account = accountArray[0].name;
    } else {
        account = DUMMY_ACCOUNT_NAME;
    }
    AccountUtils
            .setActiveAccount(InstrumentationRegistry.getTargetContext(),
                    account);
    return account;
}
 
开发者ID:google,项目名称:iosched,代码行数:21,代码来源:LoginUtils.java

示例3: getPositiveListener

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
@Override
protected View.OnClickListener getPositiveListener() {
    return new WelcomeFragmentOnClickListener(mActivity) {
        @Override
        public void onClick(View v) {
            // Ensure we don't run this fragment again
            LOGD(TAG, "Marking attending flag.");
            AccountUtils.setActiveAccount(mActivity, mSelectedAccount.toString());
            doNext();
        }
    };
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:13,代码来源:AccountFragment.java

示例4: performPostSignInTasks

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
 * Called once a user has signed in.
 *
 * @param acct   The sign in account.
 * @param result The sign in result.
 */
private void performPostSignInTasks(GoogleSignInAccount acct, GoogleSignInResult result) {

    final Activity activity = getActivity();
    if (activity == null) {
        return;
    }

    final SignInListener signInListener = getSignInListener();
    if (signInListener == null) {
        return;
    }

    // Tasks we always want to execute upon sign in.

    // Update SharedPreferences with account values.
    AccountUtils.setActiveAccount(activity, acct.getEmail());
    AccountUtils.setActiveAccountDisplayName(activity, acct.getDisplayName());
    AccountUtils.setActiveAccountPhotoUrl(activity, acct.getPhotoUrl());
    AccountUtils.setActiveAccountId(activity, acct.getId());

    // Perform Firebase auth
    firebaseAuthWithGoogle(acct);

    // Register this account/device pair within the server.
    registerWithServer(activity, acct.getId(), true);

    // Note: Post Sign in work related to user data is done in the following service.
    // This also includes calling the sync for user data.
    PostSignInUpgradeService.upgradeToSignedInUser(
            activity, AccountUtils.getActiveAccountName(activity));

    // Tasks executed by the binding activity on sign in.
    signInListener.onSignIn(result);
    AnalyticsHelper.setUserSignedIn(true);
}
 
开发者ID:google,项目名称:iosched,代码行数:42,代码来源:SignInManager.java

示例5: selectFirstAccount

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
private void selectFirstAccount() {
    List<Account> availableAccounts = new ArrayList<>(
            Arrays.asList(AccountManager.get(InstrumentationRegistry.getTargetContext())
                                        .getAccountsByType(
                                                GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE)));
    if (availableAccounts.size() > 0) {
        AccountUtils.setActiveAccount(InstrumentationRegistry.getTargetContext(),
                availableAccounts.get(0).name);
    }
}
 
开发者ID:google,项目名称:iosched,代码行数:11,代码来源:BaseActivityTestRule.java


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