1

我想单独获取特定的呼叫类型并将其从 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 )"

给我一些提示以从日志中删除特定的呼叫类型

4

1 回答 1

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/

于 2012-05-27T03:15:38.810 回答