Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

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

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 books, the developers reference and googled this to death and am reasonably sure that my code is correct. However, when I actually make the call to update(), the result is that no record is updated. My code sample is below.

Before you ask:
- I have permissions for WRITE_CONTACTS
- The record to be updated (0) does exist
- I have tried this on both a DroidX (Verizon) and a Samsung Galaxy (AT&T) - I have tried various other, longer forms of this code with same result

Can someone please help with this?

    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(
    ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, 0), 
    newValues,null,null);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...