I have facing very critical issue. I developing call log related apps but when i getting call log from content provider i am not able to find CallLog.Calls.CACHED_PHOTO_URI. It's always returning empty. I am using VIVO 1917( Funtouch OS_10)
public static void loadData(Context context) {
mainList = new ArrayList<>();
String projection[] = {"_id", CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.DURATION, CallLog.Calls.CACHED_PHOTO_URI, CallLog.Calls.TYPE, CallLog.Calls.CACHED_NAME};
ContentResolver contentResolver = context.getApplicationContext().getContentResolver();
Cursor cursor = contentResolver.query(CallLog.Calls.CONTENT_URI, projection, null, null, CallLog.Calls.DEFAULT_SORT_ORDER);
if (cursor == null) {
Log.d("CALLLOG", "cursor is null");
return;
}
if (cursor.getCount() == 0) {
Log.d("CALLLOG", "cursor size is 0");
return;
}
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
CallLogInfo callLogInfo = new CallLogInfo();
callLogInfo.setName(cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME)));
callLogInfo.setNumber(cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER)));
callLogInfo.setCallType(cursor.getString(cursor.getColumnIndex(CallLog.Calls.TYPE)));
callLogInfo.setDate(cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE)));
callLogInfo.setDuration(cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DURATION)));
String ss = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_PHOTO_URI));
Log.e("TAG", " recent calls " + ss);
mainList.add(callLogInfo);
cursor.moveToNext();
}
cursor.close();
}
Documentation from Android:
This means depending on the Dialer App which differs from manufacturers this value may not be present.
You might have a better chance by looking up the number/name in the contacts yourself and get an image this way.