Skip to content

Instantly share code, notes, and snippets.

@zimdo
Created November 5, 2012 17:43
Show Gist options
  • Save zimdo/4018924 to your computer and use it in GitHub Desktop.
Save zimdo/4018924 to your computer and use it in GitHub Desktop.
Android Account Picker
AccountManager mAccountManager = AccountManager.get(this);
Account[] accounts = mAccountManager.getAccounts(); //.getAccountsByType();
for(Account account : accounts) {
Log.d(TAG,account.name);
Log.d(TAG,account.type);
}
startActivityForResult(AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"}, false, null, null, null, null), PICK_ACCOUNT_REQUEST);
....
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if (requestCode == PICK_ACCOUNT_REQUEST && resultCode == RESULT_OK) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
Log.d(TAG, accountName + " was chosen");
}
}
@sbmaggarwal
Copy link

What gradle dependency you used for this? Including compile 'com.google.android.gms:play-services:9.0.2' can lead to 65k limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment