我面临着非常关键的问题。我正在开发与通话记录相关的应用程序,但是当我从内容提供商处获取通话记录时,我无法找到 CallLog.Calls.CACHED_PHOTO_URI。它总是返回空。我正在使用 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();
}