Calllogs returning all logs calls as well as sms l

2019-04-27 01:48发布

I am trying to get all the Call-Logs excluding SMS but i get a merged list.

How can i filter call logs for calls only?

I am using following code.

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
);

I am using Samsung Note 2 for testing.

2条回答
Deceive 欺骗
2楼-- · 2019-04-27 02:45

I have the same issue on both of my samsung devices. Researching this issue indicates it is problem with how samsung handles the android logs, it merges them. Obviously this is incorrect and inconsistent behavior. Note, an sms message cannot be deleted through the call log api, yet it can be retrieved through the call log api.

查看更多
我只想做你的唯一
3楼-- · 2019-04-27 02:51

CallLog.Calls provides feature to clarify, Incomming, Outgoing and Missed. All type of CallLog.Calls where its get other records also.

See below code:

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;

                     }
查看更多
登录 后发表回答