Custom ContactsDirectoryProvider is not called for some operations

后端 未结 1 1576
不知归路
不知归路 2021-02-19 06:42

I\'ve implemented custom ContactsDirectoryProvider which works fine when Contacts or Dialer applications are searching for contacts using URIs of the form content://

相关标签:
1条回答
  • 2021-02-19 07:31

    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

    0 讨论(0)
提交回复
热议问题