How can I update the contents of an entry in the Call Log?

后端 未结 3 1448
情话喂你
情话喂你 2020-12-15 14:50

I would like to update the CallLog.Calls.TYPE field of the first entry in the Android Call Log from MISSED to INCOMING. I have read b

相关标签:
3条回答
  • 2020-12-15 14:57

    If you update your code above and replace the line:

    ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, 0)
    

    with this line:

    Uri.parse("content://call_log/calls")
    

    It works. I don't know why, but something is not correct with the content URI.

    example:

    ContentValues newValues = new ContentValues();
    newValues.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE);
    newValues.put(CallLog.Calls.DURATION, 50);
    int result = OsmoService.context.getContentResolver().update(
        Uri.parse("content://call_log/calls"), 
        newValues,
        null,
        null);
    
    0 讨论(0)
  • 2020-12-15 15:17
    ContentValues cv = new ContentValues();
    cv.put(CallLog.Calls.NUMBER,"7070770"); // contact number
    
    cv.put(CallLog.Calls.TYPE,1); // type
    
    cv.put(CallLog.Calls.DURATION, 120); // duration in second
    
    
    getContentResolver().insert(CallLog.CONTENT_URI, cv);
    
    0 讨论(0)
  • 2020-12-15 15:23

    for example CallLog.Calls.CACHED_NAME

    private void updateCachedName(int id, @NonNull String name) {
    
        ContentValues contentValues = new ContentValues();
        contentValues.put(CallLog.Calls.CACHED_NAME, name);
    
        if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_CALL_LOG) == PackageManager.PERMISSION_GRANTED) {
    
            getContext().getContentResolver().update(CallLog.Calls.CONTENT_URI, contentValues, CallLog.Calls._ID + "=" + id, null);
        }
    }
    
    0 讨论(0)
提交回复
热议问题