8

我正在尝试获取所有内容,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
);

我正在使用三星 Note 2 进行测试。

4

2 回答 2

0

CallLog.Calls 提供澄清、来电、去电和未接电话的功能。所有类型的 CallLog.Calls 也获取其他记录。

见下面的代码:

游标 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;

                     }
于 2014-06-25T11:45:16.533 回答
0

我的两个三星设备都有同样的问题。研究这个问题表明三星处理android日志的方式存在问题,它将它们合并。显然,这是不正确且不一致的行为。注意,短信不能通过通话记录API删除,但可以通过通话记录API检索。

于 2012-12-26T15:38:47.800 回答