以编程方式将Android应用程序与联系人/电话簿链接
我目前正在编写一个应用程序,该应用程序可以扩展标准的Android联系人/电话簿.用户可以添加与特定联系人关联的一些信息/内容.我希望标准电话簿在每个联系人中显示指向我的应用程序的链接,该链接在我的应用程序中具有其他数据.例如, WhatsApp 可以做到这一点.如果您电话簿中的某人拥有WhatsApp帐户,则电话簿将在联系人旁边显示一个小的WhatsApp图标.如果您单击图标,WhatsApp将自动开始与该特定人员的聊天.
I'm currently writing an App which allows to extend the standart Android contacts / phonebook. The user can add some informations / content associated with a specific contact. I want the standart phonebook to show an link to my application on every contact which has additional data in my application. For example WhatsApp is able to do so. If somebody from you phonebook has an WhatsApp account the phonebook displays a small WhatsApp icon next to the contact. If you hit the icon WhatsApp starts automatically a chat with this specific person.
我的问题是现在如何实现?如果有人可以指出正确的方向,那将是很好的.
My question is now how this can be achieved ? If someone can point me in the right direction it would be great.
我想必须以某种方式用ContentProvider
完成.我已经指定了ContentProvider
,但是我不知道如何告诉Contacts应用程序该应用程序存在,或者我需要在哪里注册此提供程序.
I guess it must be done somehow with an ContentProvider
. I already specified an ContentProvider
but I don't know how to tell the Contacts app that this one exist or where I need to register this provider.
您需要使用联系人提供商.类ContactsContract.Contacts
提供对android mobile中所有可用联系人的访问.
You need to use Contacts Provider. Class ContactsContract.Contacts
provide access to all the contacts available in android mobile.
您需要在应用清单中具有读取联系人"权限.
You need to have Read contacts permission in your app manifest.
<uses-permission android:name="android.permission.READ_CONTACTS" />
请参阅以下Android开发者网站. http://developer.android.com/training/contacts-provider/index. html
Refer following Android developer site. http://developer.android.com/training/contacts-provider/index.html
可以在 http://developer.android.com/shareables上下载源代码./training/ContactsList.zip