我已经实现了自定义的ContactsDirectoryProvider,当联系人或拨号器应用程序使用content://com.android.contacts/data/phones/filter形式的URI搜索联系人时,它工作得很好
但是,当InCallUI或CallLog尝试使用query content:/contacts/phone_lookup检索联系人信息时,不会调用我的提供者的query方法。
有什么建议,请……
附言:我没有实现单独的同步提供程序,也许这就是问题所在?
发布于 2019-02-28 20:12:58
我们使用的一种解决方法是使用BroadcastReceiver监听来电:
<receiver android:name=".domain.callerid.CallerIdBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
然后,在BroadcastReceiver的onReceive方法中,您可以获得传入号码:
intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)
(需要READ_CALL_LOG权限,从Android Pie开始)
然后,您可以使用来电号码来匹配一个人,并显示吐司和/或通知
https://stackoverflow.com/questions/43741444
复制