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.
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
Related
I was wondering if I could provide a link to be followed by a web browser (most specifically in a QRCODE) to insert a contact with the contact data already filled. I tried content://com.android.contacts in my mobile firefox but it crashed. I also couldn't find any absolute URI for this in the Android documentation. Is it possible?
If you want to do this with QR code, another phone should always have program which can parse QR code information and call system method to add contact.
But in Android you can programmatically share contact.
This link can be helpful: How to share a contact programatically in android
I am creating a custom app for planning events. It has a SMS based authentication. Now I want to create a list of people who are already using the app (like the list of contacts in WhatsApp). Is there any way to do this in Android?
If I get you right, you can do this in 3 steps:
When a user registers on your app, save the user in say "ActiveNumbers" database on your server.
Ask contacts permission from users.
Do a join of the contacts and ActiveNumbers table, list the valid contacts in the people section of your app.
Does it solve your problem?
I'm writing a custom Android contacts directory, I have implemented the ContactsContract.Directory provider and the search from within the phone app works fine.
The problem I am facing now is that when I have an incoming/outgoing call the Android dialer does not query the custom directory I registered. Is it possible to partake in caller ID resolution via PhoneLookup or some other way?
Also as a possible workaround I have tried implementing an outgoing/incoming call interceptor with BroadcastReceiver but I see no way of returning the contact data to the dialer. The only option I have found for displaying the data is to overlay a transparent activity over the native dialer. Is there a way to return contact data back to the dialer that sent the broadcast? Any other ideas I could try?
PS. Google uses the functionality I'm trying to implement for nearby places directory listings and Caller ID by Google.
PPS. By reading the ContactsContract implementation of PhoneLookup I stumbled upon corporate contacts directory that can be appended to the user profile's default directory, according to the code it should get queried for PhoneLookup, so I'm going to try that on Monday.
In the Android Contacts application, non-local contacts have a icon to indicate the source of the contact (e.g. Google contact, Skype contact). My application is showing all the contacts and I want to show the source using the same icon. However, I don't want to maintain my own set of icons. Is it possible to get this icon from the ContactProvider. I found the API that provided the contact a/c info but don't see the constant for icon. Is it possible to get this icon. If yes then how?
Thanks
I think the CONTACT_STATUS_ICON might be what you're looking for. Not 100% sure though.
Finally figured out the way to do this. Here are the steps:
Get Contact's ACCOUN_TYPE.
Add GET_ACCOUNTS permission in the manifest file.
Get the Account using AccountManager getAccountsByType. Note that this returns an array but we can assume that all of them have the same icon (for the same account type), so just fetch the first one.
Now get the icon for the account using the code from here
I am trying to add these functionality in my Android app:
1) Get A list of suggested contacts from a Web Service and Display them in a list view
- This I have implemented and working fine
2) When User selects any of these contacts I want to present them in Native Contact View. My fried who is iPhone developer was able to do this with help of ABPerson class which provides feature to display the contact in native contact view page without adding the contact to contact list. I am not able to find any such API in Andoid. Please suggest.
3) When User want to edit any contact in the above list, I am able to present Edit Contact activity from native Phone Book app. This is working fine, but I am not able to remove the Done and Revert button. Unfortunately due to this, if user click on Done that contact is added to phone, however, what I want to do here is that, user can modify the data and I will keep it in the memory till the export process starts. During the export process I will insert these records in the Phone Book.
Please suggest me how can I do this.
I would advise you look over the BusinessCard sample and ContactManager sample posted on the Android developer site.
Reading carefully through both of these is what helped me understand exactly what's going on in the contacts API.