我试图让所有的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
);
我使用三星注2进行测试。
我有两个我的三星设备的同样的问题。 研究这个问题,表明它是与三星是如何处理的Android日志问题,将它们合并。 显然,这是不正确的,不一致的行为。 请注意,短信无法通过通话记录API被删除,但它可以通过呼叫日志API检索。
CallLog.Calls提供功能明确,进来的,传出和未接。 所有类型CallLog.Calls那里得到了其他记录也。
请参见下面的代码:
光标managedCursor = getActivity()getContentResolver()的查询(CallLog.Calls.CONTENT_URI,NULL,NULL,NULL,NULL)。; INT数= managedCursor.getColumnIndex(CallLog.Calls.NUMBER); INT名称= managedCursor.getColumnIndex(CallLog.Calls.CACHED_NAME); 整型= managedCursor.getColumnIndex(CallLog.Calls.TYPE); INT日期= managedCursor.getColumnIndex(CallLog.Calls.DATE); INT新呼叫= 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;
}
文章来源: Calllogs returning all logs calls as well as sms logs, how can i filter only call logs?