Last active
April 3, 2018 12:00
-
-
Save andrew-codechimp/647d4ba5c2862f02319d to your computer and use it in GitHub Desktop.
[getAccount] #Android
This file contains 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
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