It was pretty easy to get a contact image when People.CONTENT_URI , with a simple
People.loadContactPhoto(activity, ContentUris.withAppendedId(People.CONTENT_URI, contactId)
because i knew contact id. Now I need to do the same after entering the call log. FROM:
String[] strFields = { android.provider.CallLog.Calls.CACHED_NAME, android.provider.CallLog.Calls.NUMBER, }; String strUriCalls="content://call_log/calls"; Uri UriCalls = Uri.parse(strUriCalls); Cursor cursorLog = this.getContentResolver().query(UriCalls, strFields, null, null, null);
I get the list from the call log, but I canβt find a way to associate it with the contact ID needed to upload the photo. The application works from api level 4+.
Any help is appreciated. Thank.
The solution, according to Christian below, works for me:
private long getContactIdFromNumber(String number) { String[] projection = new String[]{Contacts.Phones.PERSON_ID}; Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL,Uri.encode(number)); Cursor c = getContentResolver().query(contactUri, projection, null, null, null); if (c.moveToFirst()) { long contactId=c.getLong(c.getColumnIndex(Contacts.Phones.PERSON_ID)); return contactId; } return -1; }
android contacts calllog android-contacts
Alin Jul 07 '11 at 17:38 2011-07-07 17:38
source share