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.