Skip to content

Instantly share code, notes, and snippets.

@clholgat
Created April 11, 2012 19:05
Show Gist options
  • Save clholgat/2361467 to your computer and use it in GitHub Desktop.
Save clholgat/2361467 to your computer and use it in GitHub Desktop.
AlertDialog.Builder builder = new AlertDialog.Builder(this);
AccountManager mgr = AccountManager.get(this);
Account[] accts = mgr.getAccountsByType("com.google");
final String[] items = new String[accts.length];
for(int i = 0; i < accts.length; i++){
items[i] = accts[i].name;
}
builder.setTitle("Choose Account To Log Into SilverBullet");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
SharedPreferences.Editor editor = settings.edit();
editor.putString("UserName", items[item]);
editor.commit();
//Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
alert = builder.create();
alert.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment