AccountPicker | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - Get Started
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
    - Get the SDK
  - Google Services
- - Google Play
  - Publishing
  - Promoting
  - App Quality
  - Spotlight
  - Open Distribution

## Results

Loading...
Summary: Methods | Inherited Methods | [Expand All]
public final class

# AccountPicker

extends Object

java.lang.Object
↳ | com.google.android.gms.common.AccountPicker

## Class Overview

Common account picker similar to the standard framework account picker introduced in ICS: `newChooseAccountIntent`.

## Summary

Public Methods
static Intent | newChooseAccountIntent(Account selectedAccount, ArrayList<Account> allowableAccounts, String[] allowableAccountTypes, boolean alwaysPromptForAccount, String descriptionOverrideText, String addAccountAuthTokenType, String[] addAccountRequiredFeatures, Bundle addAccountOptions) Returns an intent to an `Activity` that prompts the user to choose from a list of accounts.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## Public Methods

#### public static Intent newChooseAccountIntent (Account selectedAccount, ArrayList<Account> allowableAccounts, String[] allowableAccountTypes, boolean alwaysPromptForAccount, String descriptionOverrideText, String addAccountAuthTokenType, String[] addAccountRequiredFeatures, Bundle addAccountOptions)

Returns an intent to an `Activity` that prompts the user to choose from a list of accounts. The caller will then typically start the activity by calling `startActivityForResult(intent, ...);`.

On success the activity returns a Bundle with the account name and type specified using keys `KEY_ACCOUNT_NAME` and `KEY_ACCOUNT_TYPE`.

The most common case is to call this with one account type, e.g.:

     Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"},
             false, null, null, null, null);
     startActivityForResult(intent, SOME_REQUEST_CODE);

The account picker activity will return when use has selected and/or created an account, and the resulting account name can be retrieved as follows:

     protected void onActivityResult(final int requestCode, final int resultCode,
             final Intent data) {
         if (requestCode == SOME_REQUEST_CODE && resultCode == RESULT_OK) {
             String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
       }
     }

##### Parameters

selectedAccount | if specified, indicates that the `Account` is the currently selected one, according to the caller's definition of selected.
allowableAccounts | an optional `ArrayList` of accounts that are allowed to be shown. If not specified then this field will not limit the displayed accounts.
allowableAccountTypes | an optional string array of account types. These are used both to filter the shown accounts and to filter the list of account types that are shown when adding an account.
alwaysPromptForAccount | if set the account chooser screen is always shown, otherwise it is only shown when there is more than one account from which to choose
descriptionOverrideText | if non-null this string is used as the description in the accounts chooser screen rather than the default
addAccountAuthTokenType | this string is passed as the `addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback, Handler)` authTokenType parameter
addAccountRequiredFeatures | this string array is passed as the `addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback, Handler)` requiredFeatures parameter
addAccountOptions | This `Bundle` is passed as the `addAccount(String, String, String[], Bundle, Activity, AccountManagerCallback, Handler)` options parameter

##### Returns

- an `Intent` that can be used to launch the ChooseAccount activity flow.