以编程方式将Android应用程序与联系人/电话簿链接 [英] Link Android application with contacts/phonebook programmatically

查看:73
本文介绍了以编程方式将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

这篇关于以编程方式将Android应用程序与联系人/电话簿链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆