How to add new field(s) and records to the call logs(call history) database?

后端 未结 2 1073
夕颜
夕颜 2021-02-06 08:18

I am trying to make a VoIP application and I wanted to know if it is possible to do the following with the Call Logs content provider -

  1. I want to add new Call L

2条回答
  •  广开言路
    2021-02-06 09:09

    Regarding the first question, you can use this code to add new records to the existing Call logs content provider:

    public static void insertPlaceholderCall(ContentResolver contentResolver, String number){
        ContentValues values = new ContentValues();
        values.put(CallLog.Calls.NUMBER, number);
        values.put(CallLog.Calls.DATE, System.currentTimeMillis());
        values.put(CallLog.Calls.DURATION, 0);
        values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
        values.put(CallLog.Calls.NEW, 1);
        values.put(CallLog.Calls.CACHED_NAME, "");
        values.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0);
        values.put(CallLog.Calls.CACHED_NUMBER_LABEL, "");
        Log.d(TAG, "Inserting call log placeholder for " + number);
        contentResolver.insert(CallLog.Calls.CONTENT_URI, values);
    }
    

    (Code taken from Google Voice Callback for Android)

    Remember to add the permissions in the Manifest

    
    
    

    Regarding the customization of the call logs database, I do not think is possible.

提交回复
热议问题