Skip to content

Instantly share code, notes, and snippets.

@creativepsyco
Created January 19, 2016 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativepsyco/54a537750c6682a719dc to your computer and use it in GitHub Desktop.
Save creativepsyco/54a537750c6682a719dc to your computer and use it in GitHub Desktop.
Get account info from the phone. Requires ACCOUNT Permission in the manifest.
Account[] accounts = AccountManager.get(getView().getContext()).getAccounts();
Set<String> emailSet = new HashSet<>();
for (Account account : accounts) {
if (EMAIL_PATTERN.matcher(account.name).matches()) {
emailSet.add(account.name);
}
}
getView().txtPlaceName.setAdapter(new ArrayAdapter<>(getView().getContext(),
android.R.layout.simple_dropdown_item_1line, new ArrayList<>(emailSet)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment