我想单独获取特定的调用类型,并将其从android中的调用日志中删除。
while (cursor.moveToNext()) {
String queryString1= "CallType=’" + CallLog.Calls.MISSED_TYPE + "‘";
Log.v("CallType", queryString1);
if(CallLog.Calls.TYPE.equals("missed")) {
sb.append("Number "+CallLog.Calls.NUMBER+"\nName "+CallLog.Calls.CACHED_NAME);
}
}
getContentResolver().delete(UriCalls, CallLog.Calls.MISSED_TYPE, null);
这是我为错过的调用而尝试的代码,因为Missed_type是int,我收到错误“ContentResolver类型中的方法delete(Uri,String,String [])不适用于参数(Uri, int,null)“
给我一些从日志中删除特定呼叫类型的提示
答案 0 :(得分:1)
您可以使用以下代码获取未接来电提醒
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = android.provider.CallLog.Calls.DATE + " DESC";
Cursor cursor = null;
try{
cursor = context.getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
while (cursor.moveToNext()) {
String callLogID = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls._ID));
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
String callDate = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.DATE));
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
String isCallNew = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NEW));
if(Integer.parseInt(callType) == MISSED_CALL_TYPE && Integer.parseInt(isCallNew) > 0){
if (_debug) Log.v("Missed Call Found: " + callNumber);
}
}
} catch(Exception ex){
if (_debug) Log.e("ERROR: " + ex.toString());
}finally{
cursor.close();
}
您也可以使用此链接http://android2011dev.blogspot.in/2011/08/get-android-phone-call-historylog.html
<uses-permission android:name="android.permission.READ_LOGS"></uses-permission>
在 androidmanifest.xml
中授予以上权限使用以下链接删除未接来电列表,您只需要传递您从上面的代码中获得的号码
http://www.mobisoftinfotech.com/blog/android/androidcalllogdeletion/