Reputation: 3926
I have a mobile number and I am able to detect that mobile number with relevant contacts but how to take user to see the contact details via default contact application in android.
i.e.
If he clicks the mobile number it should take him to the contact page in phone application.
Suppose if 999999999 is there in phone contacts then after clicking it, it should take him to the contacts page(Default by phone).
How to achieve this...
Upvotes: 2
Views: 312
Reputation: 12181
You can try to call the intent with ACTION_VIEW, but you will need the contact ID before hand...
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactID));
intent.setData(uri);
context.startActivity(intent);
Edit:
To get a contact id from contact number:
public static int getContactIDFromNumber(String contactNumber,Context context)
{
contactNumber = Uri.encode(contactNumber);
int phoneContactID = new Random().nextInt();
Cursor contactLookupCursor = context.getContentResolver().query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.contactNumber),new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup._ID}, null, null, null);
while(contactLookupCursor.moveToNext()){
phoneContactID = contactLookupCursor.getInt(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup._ID));
}
contactLookupCursor.close();
return phoneContactID;
}
For more on Contact manipulation, have a look at this answer...
Upvotes: 2