问题
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