2

I ran into this post: How to call Android contacts list?

Unfortunately I'm reading that it's old and Android 2.0 changed how this works, but this post fails to link to a new method of accomplishing this. Google also appears to either lack results, or I'm not searching for the right thing. I'd like for a user to be able to select a contact on my app... how do I give them a prompt to select 1 user, then for a task to be executed when that user is selected.

Community
  • 1
  • 1
Ben
  • 60,438
  • 111
  • 314
  • 488

1 Answers1

2

You need to use StartActivityForResult on your contact picker Intent and then you will get the result back when the user selects the contact. Here is a pretty good example

 Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,  
        Contacts.CONTENT_URI);  
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
ninjasense
  • 13,756
  • 19
  • 75
  • 92
  • 2
    Here is a sample project that demonstrates this, and works for both the older and newer contacts APIs: https://github.com/commonsguy/cw-advandroid/tree/master/Contacts/Pick – CommonsWare Dec 27 '10 at 19:37
  • That tutorial shows `Bundle extras = data.getExtras();`.... when I do `` like that on Eclipse it says there's a problem... is that not the correct syntax? – Ben Dec 28 '10 at 03:09