android adding number to Call logs

后端 未结 2 1498
后悔当初
后悔当初 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

    <uses-permission
        android:name="android.permission.READ_CONTACTS"/>
    <uses-permission
        android:name="android.permission.WRITE_CONTACTS"/>
    
    0 讨论(0)
  • 2021-01-02 05:09

    The linked post explains it very well so I don't know why you are asking again. You cannot modify the call logs unless you keep your own database or your own firmware.

    0 讨论(0)
提交回复
热议问题