I have to select a Contact from an android device Contacts list.
With the following code I retrieve an activity with the list of the contacts on the device:
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, ADD_CONTACT_REQUEST_CODE);
After picking a contact, how can I get the LOOKUP_KEY of the selected contact?
Instead or retrieving content://com.android.contacts/contacts/lookup/0r2-334B29432D314D2D29/2
, I need to get 0r2-334B29432D314D2D29
, that is the LOOKUP_KEY
So far I'm able just to retrieve full Uri
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == Activity.RESULT_OK){
switch (requestCode){
case ADD_CONTACT_REQUEST_CODE:
Uri contactUri = data.getData();
String contactUriString = contactUri.toString();
break;
}
}
}
Thank You in advance