0

This question hasn't been answered since they deprecated the Contacts.People type, and all the answers I could find still involve its use. How can it be done without using People.NAME and People.NUMBER?

In other words, I already know that you can start the Contact List with:

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, 1);

...and then you have to create a method called onActivityResult, which has to look like this:

public void onActivityResult(int reqCode, int resultCode, Intent data) {
    super.onActivityResult(reqCode, resultCode, data);
    switch (reqCode) {
    case (1):
        if (resultCode == Activity.RESULT_OK) {
            Uri contactData = data.getData();
            Cursor c = this.getContentResolver()    
                       .query(contactData,
                            null,
                            null,
                            null,
                            null);

            if (c.moveToFirst()) {
                int contact_id = c.getInt(c
                        .getColumnIndexOrThrow(ContactsContract.?????????));
            }
        }
        break;
    }
}

...so, what non-deprecated column names should I expect to find in Cursor c? I can't find any updated documentation on this, and Google only returns examples with deprecated People.NAME and People.NUMBER columns.

The ContactsContract class is a Byzantine morass of... stuff, in which I can't find anything that looks like it has anything to do with People.NAME or People.NUMBER, so answers that say "just read the documentation for ContactsContract" are completely unhelpful.

Perhaps there is little point in editing this in after it's already been marked as [duplicate], since nobody will ever read it.

Worst of all, since I can't comment, I can't ask for clarification on other versions of this question. I have to ask a new question.

  • Have you seen the reference [here](http://developer.android.com/reference/android/provider/ContactsContract.Data.html)? I think it might be helpful. – Danny Nov 18 '13 at 18:43
  • Beyond that, feel free to explain, in detail, what "invoke Android's Contact List" means. – CommonsWare Nov 18 '13 at 18:52
  • "invoke Android's Contact List" means that the phone presents the user with the Contact List, then after the user picks a contact from the list, this data is returned to my Activity's onActivityResult method. I can't figure out how to extract the data from the Intent object passed to that method because I have no idea what columns to expect in the Cursor that can eventually be extracted from the Intent object passed to onActivityResult.. – user3005829 Dec 03 '13 at 16:18

1 Answers1

0

Refer to the following link for more information http://developer.android.com/training/contacts-provider/index.html

  • It certainly tells you how to do a lot of things with Contacts Provider, but it doesn't give me a clue as to what could serve as a drop-in replacement for example code on what to do with the data given to `onActivityResult`. I'll edit the question to make it more clear. – user3005829 Nov 19 '13 at 15:51