简体   繁体   中英

Get the missed call list and delete it from call log in android

I want to get the particular call type alone and delete it from the call log in 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);

This is a code i ve tried for missed call,because of Missed_type is int, i got an error "The method delete(Uri, String, String[]) in the type ContentResolver is not applicable for the arguments (Uri, int, null)"

Give me some tips to delete the particular call type from log

you can use following code to fetch Missed call Alert

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

You can also use this link http://android2011dev.blogspot.in/2011/08/get-android-phone-call-historylog.html

<uses-permission android:name="android.permission.READ_LOGS"></uses-permission>

Give above permission in androidmanifest.xml

use following link to delete missed call list , you just need to pass number that u got from above code

http://www.mobisoftinfotech.com/blog/android/androidcalllogdeletion/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM