ContactsDirectoryProvider

ContactsDirectoryProvider

本文介绍了某些操作未调用Custom ContactsDirectoryProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了自定义的ContactsDirectoryProvider,当Contacts或Dialer应用程序使用 content://com.android.contacts/data/phones/filter

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

但是,当InCallUI或CallLog尝试通过以下方式检索联系信息时URis content:/contacts/phone_lookup 未调用我提供者的 query 方法.

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.我没有实现单独的同步提供程序,也许这是问题所在吗?

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

推荐答案

我们正在使用的解决方法是使用BroadcastReceiver监听来电:

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>

然后在BroadcastReceiver的onReceive方法中,您可以获取传入号码:

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

intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)

(这需要以Android Pie开头的READ_CALL_LOG权限)

(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

这篇关于某些操作未调用Custom ContactsDirectoryProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 03:31