Custom ContactsDirectoryProvider is not called for some operations

无人久伴 提交于 2021-02-07 05:18:07

问题


I've implemented custom ContactsDirectoryProvider which works fine when Contacts or Dialer applications are searching for contacts using URIs of the form content://com.android.contacts/data/phones/filter

However when InCallUI or CallLog are trying to retrieve contact info with URis content:/contacts/phone_lookup the query method of my provider is not called.

Any advice please....

P.S. I did not implement separate sync provider maybe this is the problem?


回答1:


A workaround that we are using is to use a BroadcastReceiver to listen to incoming calls:

<receiver android:name=".domain.callerid.CallerIdBroadcastReceiver">
    <intent-filter>
        <action android:name="android.intent.action.PHONE_STATE" />
    </intent-filter>
</receiver>

Then in the onReceive method of the BroadcastReceiver you can get the incoming number:

intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)

(This requires the READ_CALL_LOG permission starting with Android Pie)

Then you can use the incoming number to match a person and show a toast and or notification



来源:https://stackoverflow.com/questions/43741444/custom-contactsdirectoryprovider-is-not-called-for-some-operations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!