Skip to content

Instantly share code, notes, and snippets.

@andrew-codechimp
Last active April 3, 2018 12:00
Show Gist options
  • Save andrew-codechimp/647d4ba5c2862f02319d to your computer and use it in GitHub Desktop.
Save andrew-codechimp/647d4ba5c2862f02319d to your computer and use it in GitHub Desktop.
[getAccount] #Android
private Account getAccount(String accountName) {
AccountManager manager = (AccountManager) getActivity().getSystemService(Activity.ACCOUNT_SERVICE);
Account[] list = manager.getAccounts();
for (Account account : list) {
if (account.type.equalsIgnoreCase("com.google")) {
if (account.name.equalsIgnoreCase(accountName)) {
return account;
}
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment