其他分享
首页 > 其他分享> > android – 如何更新通话记录中条目的内容?

android – 如何更新通话记录中条目的内容?

作者:互联网

我想将Android调用日志中第一个条目的CallLog.Calls.TYPE字段从MISSED更新为INCOMING.我已经阅读过书籍,开发人员参考并将其搜索到死亡,并且我有理由相信我的代码是正确的.但是,当我实际调用update()时,结果是没有更新记录.我的代码示例如下.

在你问之前:
   – 我有WRITE_CONTACTS的权限
   – 要更新的记录(0)确实存在
   – 我在DroidX(Verizon)和三星Galaxy(AT& T)都尝试了这个
   – 我尝试过各种其他更长形式的代码,结果相同

有人可以帮忙吗?

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

解决方法:

如果您更新上面的代码并替换该行:

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

用这一行:

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

有用.我不知道为什么,但内容URI的内容不正确.

例:

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

标签:android,calllog
来源: https://codeday.me/bug/20190930/1836684.html