Open native phonebook as intent and use it for searching. Possible?

android, android-intent

Solution

I found a solution to my problem thanks to my friend that linked me the same question on stackoverflow.

Basically to get contact by using vendor phonebook search app we must start intent in order to start our journey for searching.

I used it inside a button that calls this method on button click.

public void showContactsChooser(final View view){
   Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
   startActivityForResult(intent, PICK_CONTACT);
}

We now get a screen that is showing us all the contacts we have. We choose one and we are getting back to our app.

To read this contact I am using this method:

    @Override
    public void onActivityResult(int reqCode, int resultCode, Intent data){
        super.onActivityResult(reqCode, resultCode, data);

        switch(reqCode){
           case (PICK_CONTACT):
             if (resultCode == Activity.RESULT_OK){
                 Uri contactData = data.getData();
                 Cursor c = getContentResolver().query(contactData, null, null, null, null);

                 if (c.moveToFirst()){
String name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
                 Toast.makeText(getApplicationContext(), name, Toast.LENGTH_SHORT).show();
                 }
             }
        }
    }

And done :)

My knowledge comes from http://eclipsed4utoo.com/blog/android-open-contacts-activity-return-chosen-contact/ And to the author of that is going all the credit.

Problem

As the topic. I researched all day long and know I know that I can add contacts by using native phone book, send SMS via native sms application. But I can't find any way to use native phone book to search for contacts. I tried working with documentation: http://developer.android.com/reference/android/provider/ContactsContract.Intents.html#SEARCH_SUGGESTION_CLICKED And all common things related to that. My question is: Is it possible to use native phone book to search for contacts and retrieve them? If so, example much appreciated.

Original source

Related problems