问题描述
我试图让所有的通话,记录不包括短信
,但我得到一个合并的列表。
I am trying to get all the Call-Logs excluding SMS
but i get a merged list.
的如何过滤呼叫通话记录只?的
我使用以下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
);
我使用三星注2进行测试。
I am using Samsung Note 2 for testing.
推荐答案
CallLog.Calls提供功能明确,进来的,传出和未接。所有类型CallLog.Calls那里得到了其他记录也。
见下文code:
光标managedCursor = getActivity()getContentResolver()查询(CallLog.Calls.CONTENT_URI,NULL,NULL,NULL,NULL);
INT数= managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
INT NAME = 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);
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;
}
这篇关于Calllogs返回所有记录呼叫,以及短信记录,我怎么能只过滤通话记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!