本文整理汇总了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");
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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();
}
}
示例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());
}
}
示例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) {
}
}
示例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);
}
}
示例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);
}
}