old code:

ContentResolver resolver = context.getContentResolver();
Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI,
null ,null, null, null);

log:

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver com.zshfzb.autoanswer.AutoAnswerReceiver: android.database.sqlite.SQLiteException: no such column: data_id (code 1): , while compiling: SELECT CallsStat_id, ip_prefix, numberlabel, matched_number, type, date, contactid, statNew, lookup_uri, moduletype, _id, name, normalized_number, ring_count, photo_id, formatted_number, number, geocoded_location, countryiso, data_id, numbertype, new, duration, simid, isprivate, voicemail_uri, is_read, raw_contact_id, vtcall FROM calls_restrict_view
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2557)
at android.app.ActivityThread.access$1500(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: no such column: data_id (code 1): , while compiling: SELECT CallsStat_id, ip_prefix, numberlabel, matched_number, type, date, contactid, statNew, lookup_uri, moduletype, _id, name, normalized_number, ring_count, photo_id, formatted_number, number, geocoded_location, countryiso, data_id, numbertype, new, duration, simid, isprivate, voicemail_uri, is_read, raw_contact_id, vtcall FROM calls_restrict_view
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:373)
at android.content.ContentResolver.query(ContentResolver.java:316)
at com.zshfzb.PhoneUtilsFunction.modifyCallLogZuiJinRecord(PhoneUtilsFunction.java:63)
at com.zshfzb.autoanswer.AutoAnswerReceiver.onReceive(AutoAnswerReceiver.java:81)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2550)
... 10 more

修改为:

ContentResolver resolver = context.getContentResolver();
Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI,
new String[] { CallLog.Calls.DATE, CallLog.Calls.NUMBER,
CallLog.Calls.CACHED_NAME, CallLog.Calls.TYPE }, "", null, null);

就解决了

更多相关文章

  1. androdi 9.0 P版本 CTS 又出现问题了。。
  2. The following classes could not be instantiated: - android.s
  3. (Androidx)error: expected reference but got (raw string) @+and
  4. Android(安卓)Settings 开发(一) -- EditText UI 修改
  5. Android常用固件修改
  6. android 实现全屏代码
  7. 如何绑定按键与程序
  8. window 下 利用gradle编译volley源代码
  9. Android(安卓)App兼容android10.0系统需要修改那些东西,看这个就

随机推荐

  1. android修改控件外观(使用drawable资源)
  2. Android形形色色的弹出框(上)
  3. QML使MeeGo迅速崛起赶超Android变为可能
  4. Android(安卓)Activity生命周期详解
  5. Unity 接入 Facebook登录SDK7.11.1 (Andr
  6. 浅谈android中的异步加载一
  7. Android核心分析 --分析方法论探讨之设计
  8. 物联网江湖 第二回- 列王的纷争 谷歌的利
  9. 最新android studio注意事项打不开等问题
  10. android.webkit.WebView 体验1: 使用html