public void pickUserAccount() { String[] accountTypes = new String[] {"com.google"}; Intent intent = AccountPicker.newChooseAccountIntent( null, null, accountTypes, false, null, null, null, null); mActivity.startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT); }
private void pickUserAccount() { String[] accountTypes = new String[] {GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE}; Intent intent = AccountPicker.newChooseAccountIntent( null, null, accountTypes, true, "Please choose account", null, null, null); startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); info = (Button) findViewById(R.id.button3); about_us = (Button) findViewById(R.id.button2); infodialog = new CreateInfoDialog(); aboutdialog = new CreateAboutDialog(); welcomedialog = new CreateWelcomeDialog(); welcomedialog.show(getFragmentManager(), "about"); checkLocationServices(); checkConnection(getApplicationContext()); Context context = getApplicationContext(); locationManager = (LocationManager) context.getSystemService(context.LOCATION_SERVICE); criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setSpeedAccuracy(Criteria.ACCURACY_HIGH); best_provider = locationManager.getBestProvider(criteria, true); location = new Location(best_provider); latitude = location.getLatitude(); longitude = location.getLongitude(); accuracy = location.getAccuracy(); altitude = location.getAltitude(); locationManager.requestLocationUpdates(best_provider, MINTIME, MINDISTANCE, this); mResolvingError = savedInstanceState != null && savedInstanceState.getBoolean(STATE_RESOLVING_ERROR, false); buildGoogleApiClient(); deviceid = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); 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) { // Do nothing } }
/** Method to request the user choose an account. */ private boolean triggerAccountSelection() { if (!checkGooglePlayServicesAvailable()) { return false; } Intent intent = AccountPicker.newChooseAccountIntent( null, null, new String[] {"com.google"}, false, getString(R.string.auth_description), null, null, null); startActivityForResult(intent, REQ_CHOOSE_ACCOUNT); return true; }
/** * Displays an account picker to the user * * @param ctx Parent activity for the picker. This activity will have its onActivityResult called * with the resulting account. * @param requestCode This request code will be passed to onActivityResult. * @param selectedAccount If not null, this Account will be rendered as currently selected in the * picker. * @param types One or more account types. Only these types will be displayed in the picker. */ public static void launchAccountPicker( Activity ctx, int requestCode, Account selectedAccount, String... types) { Intent intent = AccountPicker.newChooseAccountIntent( selectedAccount, null, types, true, null, null, null, null); if (ctx.getPackageManager().resolveActivity(intent, 0) == null) { // User probably needs the Google Play Services library Toast.makeText(ctx, R.string.google_play_services_error, Toast.LENGTH_LONG).show(); intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.gms")); ctx.startActivity(intent); } else { ctx.startActivityForResult(intent, requestCode); } }
public static Intent getPickerIntent() { return AccountPicker.newChooseAccountIntent( null, null, new String[] {"com.google"}, false, null, null, null, null); }