android adding number to Call logs

后端 未结 2 1590
后悔当初
后悔当初 2021-01-02 04:33

Is it by anyway possible to write to call logs database?? I mean i want to add selected numbers to the call history. I tried searching the tutorial on net but couldn\'t find

2条回答
  •  心在旅途
    2021-01-02 05:09

    You can use this snippet 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

    
    
    

提交回复
热议问题