Created
November 5, 2012 17:43
-
-
Save zimdo/4018924 to your computer and use it in GitHub Desktop.
Android Account Picker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What gradle dependency you used for this? Including compile 'com.google.android.gms:play-services:9.0.2' can lead to 65k limit.