Skip to content

Instantly share code, notes, and snippets.

@ermau
Created January 2, 2012 21:50
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 ermau/1552267 to your computer and use it in GitHub Desktop.
Save ermau/1552267 to your computer and use it in GitHub Desktop.
Get a list of names, phones and emails on Android with Xamarin.Mobile
TextView t = FindViewById<TextView> (Resource.Id.status);
StringBuilder builder = new StringBuilder();
var book = new AddressBook (this);
book.PreferContactAggregation = true;
foreach (Contact c in book.Where (c => c.FirstName == "Eric"))
{
builder.AppendLine (c.DisplayName);
foreach (Phone p in c.Phones)
builder.AppendLine ("Phone: " + p.Number);
foreach (Email e in c.Emails)
builder.AppendLine ("Email: " + e.Address);
builder.AppendLine();
}
t.Text = builder.ToString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment