我正在尝试获取所有Call-Logs excluding SMS
,但我得到了一个合并列表。
如何过滤呼叫的呼叫记录?
我正在使用以下代码。
String[] strFields = {
android.provider.CallLog.Calls.NUMBER,
android.provider.CallLog.Calls.TYPE,
android.provider.CallLog.Calls.CACHED_NAME,
android.provider.CallLog.Calls.CACHED_NUMBER_TYPE,
android.provider.CallLog.Calls.DATE
};
String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
Uri calluri = Uri.parse("content://call_log/calls");
Cursor mCallCursor = getContentResolver().query(
calluri,
strFields,
null,
null,
strOrder
);
我正在使用Samsung Note 2进行测试。
答案 0 :(得分:0)
我在两个三星设备上都有同样的问题。研究这个问题表明它是三星如何处理android日志的问题,它合并它们。显然这是不正确和不一致的行为。注意,短信息不能通过呼叫记录api删除,但可以通过呼叫记录api检索。
答案 1 :(得分:0)
CallLog.Calls提供澄清,Incomming,Outgoing和Missed的功能。所有类型的CallLog.Calls也可以获得其他记录。
见下面的代码:
Cursor managedCursor = getActivity()。getContentResolver()。query(CallLog.Calls.CONTENT_URI,null,null,null,null); int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER); int name = managedCursor.getColumnIndex(CallLog.Calls.CACHED_NAME); int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE); int date = managedCursor.getColumnIndex(CallLog.Calls.DATE); int newcall = managedCursor.getColumnIndex(CallLog.Calls.NEW); int callduration = managedCursor.getColumnIndex(CallLog.Calls.DURATION); int id = managedCursor.getColumnIndex(CallLog.Calls._ID);
while ( managedCursor.moveToNext() ) {
callNumber = managedCursor.getString( number );
callName = managedCursor.getString(name);
callType = managedCursor.getString( type );
callDate = managedCursor.getString( date );
isCallNew = managedCursor.getString(newcall);
Date callDayTime = new Date(Long.valueOf(callDate));
duration = managedCursor.getString( callduration );
contactId = managedCursor.getString(id);
// process log data...
Log.i("Call Name-----", callNumber);
String cType = null;
int cTypeCode = Integer.parseInt(callType);
switch(cTypeCode)
{
case CallLog.Calls.OUTGOING_TYPE:
cType = "OUTGOING";
break;
case CallLog.Calls.INCOMING_TYPE:
cType= "INCOMING";
break;
case CallLog.Calls.MISSED_TYPE:
cType = "MISSED";
break;
}