Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link Android application with contacts/phonebook programmatically

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.

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.

like image 903
Westranger Avatar asked Jan 07 '15 09:01

Westranger


1 Answers

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" />

Refer following Android developer site. http://developer.android.com/training/contacts-provider/index.html

Source code can be downloaded at http://developer.android.com/shareables/training/ContactsList.zip

like image 83
Jeno Karthic Avatar answered Oct 21 '22 04:10

Jeno Karthic