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


Java AccountPicker类代码示例

本文整理汇总了Java中com.google.android.gms.common.AccountPicker的典型用法代码示例。如果您正苦于以下问题:Java AccountPicker类的具体用法?Java AccountPicker怎么用?Java AccountPicker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AccountPicker类属于com.google.android.gms.common包,在下文中一共展示了AccountPicker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pickUserAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
private void pickUserAccount() {
    try {
        String[] accountTypes = new String[]{"com.google"};
        Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                accountTypes, true, null, null, null, null);
        if ( activity == null )
            return;
        // check if play-services are installed
        int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
        if (ConnectionResult.SUCCESS == result) {
            activity.startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);
            logger.debug("Launching google account picker ...");
        } else {
            // display user friendly error message
            logger.debug("Play services are missing ...");
            GooglePlayServicesUtil.getErrorDialog(result, activity, 100).show();
        }
    } catch (ActivityNotFoundException ex) {
        logger.debug("Google-play-services are missing? cannot login by google");
    }
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:22,代码来源:GoogleOauth2.java

示例2: onResume

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
@Override
public void onResume() {
	super.onResume();
	
	if (!SettingsUtil.isAccountSelected(getActivity())) {

		final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity().getApplicationContext());
		if (status == ConnectionResult.SUCCESS) {

			startActivityForResult(
					AccountPicker.newChooseAccountIntent(null, null, new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE }, false, null, null, null, null),
					UserSettingsActivity.REQUEST_CODE_ACCOUNT_NAME);

		} else {

			GooglePlayServicesUtil.getErrorDialog(status, getActivity(), UserSettingsActivity.REQUEST_CODE_PLAY_SERVICES_NOT_AVAILABLE).show();
		}
	}
	initLoader();
	
	getLoaderManager().restartLoader(ILoader.COURSES_LOADER_ID, null, this);
}
 
开发者ID:gwario,项目名称:coasy,代码行数:23,代码来源:CourseListFragment.java

示例3: onResume

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
@Override
public void onResume() {
	super.onResume();
	
	if (!SettingsUtil.isAccountSelected(getActivity())) {

		final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity().getApplicationContext());
		if (status == ConnectionResult.SUCCESS) {

			startActivityForResult(
					AccountPicker.newChooseAccountIntent(null, null, new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE }, false, null, null, null, null),
					UserSettingsActivity.REQUEST_CODE_ACCOUNT_NAME);

		} else {

			GooglePlayServicesUtil.getErrorDialog(status, getActivity(), UserSettingsActivity.REQUEST_CODE_PLAY_SERVICES_NOT_AVAILABLE).show();
		}
	}
	
	getLoaderManager().restartLoader(ILoader.STUDENTS_LOADER_ID, null, this);
}
 
开发者ID:gwario,项目名称:coasy,代码行数:22,代码来源:StudentListFragment.java

示例4: onPreferenceClick

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {

	if (preference.getKey().equals(getString(R.string.btnSelectGoogleAccount_key))) {

		final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity().getApplicationContext());
		if (status == ConnectionResult.SUCCESS) {

			startActivityForResult(AccountPicker.newChooseAccountIntent(SettingsUtil.getSelectedGoogleAccount(getActivity()), null,
					new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE }, false, null, null, null, null), UserSettingsActivity.REQUEST_CODE_ACCOUNT_NAME);
			return true;

		} else {

			GooglePlayServicesUtil.getErrorDialog(status, getActivity(), UserSettingsActivity.REQUEST_CODE_PLAY_SERVICES_NOT_AVAILABLE).show();
		}
		
	}
	return true;
}
 
开发者ID:gwario,项目名称:coasy,代码行数:21,代码来源:UserSettingsActivity.java

示例5: selectAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
private void selectAccount() {
    Account[] accounts = Utils.getGoogleAccounts(this);
    int numOfAccount = accounts.length;
    switch (numOfAccount) {
        case 0:
            // No accounts registered, nothing to do.
            Toast.makeText(this, R.string.toast_no_google_accounts_registered,
                    Toast.LENGTH_LONG).show();
            break;
        case 1:
            mEmailAccount = accounts[0].name;
            performAuthCheck(mEmailAccount);
            break;
        default:
            // More than one Google Account is present, a chooser is necessary.
            // Invoke an {@code Intent} to allow the user to select a Google account.
            Intent accountSelector = AccountPicker.newChooseAccountIntent(null, null,
                    new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE}, false,
                    getString(R.string.select_account_for_access), null, null, null);
            startActivityForResult(accountSelector, ACTIVITY_RESULT_FROM_ACCOUNT_SELECTION);
    }
}
 
开发者ID:udacity,项目名称:conference-central-android-app,代码行数:23,代码来源:MainActivity.java

示例6: signin

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
@Kroll.method
public void signin(KrollDict props)
{
	if (props.containsKey("success")) {
		successCallback = (KrollFunction) props.get("success");
	}
	if (props.containsKey("error")) {
		errorCallback = (KrollFunction) props.get("error");
	}
	

	String[] accountTypes = new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE };
	Intent intent = AccountPicker.newChooseAccountIntent(null, null,
			accountTypes, false, null, null, null, null);

	Activity activity = TiApplication.getAppCurrentActivity();
	TiActivitySupport support = (TiActivitySupport) activity;
	requestCode = support.getUniqueResultCode();
	support.launchActivityForResult(intent, requestCode, this);

}
 
开发者ID:Sitata,项目名称:titanium_google_auth_util,代码行数:22,代码来源:TitaniumGoogleAuthUtilModule.java

示例7: enforceActiveGoogleAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
/**
 * Enforce an active Google Account by checking to see if an active account is already set. If
 * it is not set then use the {@link AccountPicker} to have the user select an account.
 *
 * @param activity The context to be used for starting an activity.
 * @param activityResultCode The result to be used to start the {@link AccountPicker}.
 * @return Returns whether the user already has an active account registered.
 */
public static boolean enforceActiveGoogleAccount(Activity activity, int activityResultCode) {
    if (hasActiveAccount(activity)) {
        return true;
    } else {
        Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE},
                true, null, null, null, null);
        activity.startActivityForResult(intent, activityResultCode);
        return false;
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:20,代码来源:AccountUtils.java

示例8: chooseAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
private void chooseAccount() {
    try {
        Account selectedAccount = getSelectedAccount();
        Intent intent = AccountPicker.newChooseAccountIntent(selectedAccount, null, ACCOUNT_TYPE, true,
                null, null, null, null);
        startActivityForResult(intent, CHOOSE_ACCOUNT);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, R.string.google_drive_account_select_error, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:11,代码来源:PreferencesActivity.java

示例9: chooseAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
/**
 * Pick up a Google account from the device. See http://developer.android.com/google/auth/http-auth.html.
 */
public void chooseAccount()
{
	String[] accountTypes = new String[]{"com.google"};
	Intent intent = AccountPicker.newChooseAccountIntent(null, null, accountTypes, false, null, null, null, null);
	startActivityForResult(intent, IntentRequestCode.REQUEST_ACCOUNT_PICKER);
}
 
开发者ID:jayxue,项目名称:YouTubeUploader,代码行数:10,代码来源:UploadVideoActivity.java

示例10: pickUserAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
private void pickUserAccount() {
    String[] accountTypes = new String[]{"com.google"};
    Intent mIntent = AccountPicker.newChooseAccountIntent(null, null,
            accountTypes, false, null, null, null, null);
    if (mIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(mIntent, REQUEST_CODE_PICK_ACCOUNT);
    }
}
 
开发者ID:ganesh2shiv,项目名称:yt-channel-list-android,代码行数:9,代码来源:HomeActivity.java

示例11: chooseFlowzrAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
private void chooseFlowzrAccount() {
    try {
        Account selectedAccount = getFlowzrSelectedAccount();
        Intent intent = AccountPicker.newChooseAccountIntent(selectedAccount, null, ACCOUNT_TYPE, true,
                null, null, null, null);
        startActivityForResult(intent, CHOOSE_ACCOUNT);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, R.string.google_drive_account_select_error, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:11,代码来源:FlowzrPreferencesActivity.java

示例12: askUserEmail

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
private void askUserEmail() {
    try {
        Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE}, false, null, null, null, null);
        startActivityForResult(intent, REQUEST_CODE_EMAIL);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, e.getMessage());
    }
}
 
开发者ID:SNiels,项目名称:Multi-Mania-app,代码行数:9,代码来源:SettingsFragment.java

示例13: askUserEmail

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
private void askUserEmail() {
    try {
        Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE}, false, null, null, null, null);
        startActivityForResult(intent, SettingsFragment.REQUEST_CODE_EMAIL);
    } catch (ActivityNotFoundException e) {
    }
}
 
开发者ID:SNiels,项目名称:Multi-Mania-app,代码行数:8,代码来源:MainActivity.java

示例14: pickAccount

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
/**
 * onActivityResult will be called either in the Activity/Fragment depending on whether a Fragment is attached.
 */
public void pickAccount() {
    String[] accountTypes = new String[]{ACCOUNT_TYPE_GOOGLE};
    Intent intent = AccountPicker.newChooseAccountIntent(null, null, accountTypes, false, null, null, null, null);
    if (mFragment != null) {
        mFragment.startActivityForResult(intent, REQUEST_ACCOUNT_PICKER);
    } else {
        mActivity.startActivityForResult(intent, REQUEST_ACCOUNT_PICKER);
    }
}
 
开发者ID:plusCubed,项目名称:android-picasa-client,代码行数:13,代码来源:PicasaClient.java

示例15: onCreate

import com.google.android.gms.common.AccountPicker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Shows Account Picker with google accounts if not stored in shared
    // preferences
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    Boolean accountFound = false;
    if (sharedPrefs.contains("gmailId")) {
        Account[] accounts = AccountManager.get(this)
                .getAccounts();
        accountName = sharedPrefs.getString("gmailId", null);
        for (Account a : accounts) {
            if (a.type.equals(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE)
                    && a.name.equals(accountName)) {
                accountFound = true;
                new getAuthToken().execute();
                break;
            }
        }
    }

    if (!accountFound) {
        Intent googlePicker = AccountPicker.newChooseAccountIntent(null,
                null, new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE},
                true, null, null, null, null);
        startActivityForResult(googlePicker, 1);
    }

}
 
开发者ID:RSenApps,项目名称:Commandr-Android,代码行数:30,代码来源:ReadUnreadGmailActivity.java


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