I use this code to get the contact information of a contact (I use it also - with a few changes - to call, send SMS or email a contact). I wonder if there is a way to show the call history of a specific contact:
String Name3 is the name of the contact.
contactinfobtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if (cur.getCount() > 0) { while (cur.moveToNext()) { id_contact = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); name_contact = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); if (name_contact.equals(name3)) { Cursor pCur = cr.query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", new String[]{id_contact}, null); id_contact2 = id_contact; while (pCur.moveToNext()){ } pCur.close(); } } Intent intent_contacts = new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/" + id_contact2)); startActivity(intent_contacts); } } });
source share