RSS Feed

An Android Contact Picker

Posted on Monday, December 5, 2011 in Coding

Often in Android development, there is need to support the following workflow:

  1. Display list of contacts
  2. User selects a contact
  3. Display contact details
  4. User selects a phone number
  5. Perform an action with the number

There is a standard way to call the contact list in Android, but that method pulls up a new full-screen activity for showing the contact list. When the user selects a contact, it returns the contact ID to your activity and you can do what you wish with it. However, this method does not always feel well-integrated in your app and can reduce the quality of the user experience. This is especially true  for tabbed Android applications where the contact picker needs to remain embedded within the tab.

I was surprised that an API for enabling this kind of workflow was not available on Android. Searching on StackOverflow and other forums clearly show the need. So while developing CallingProxy, I had to roll a contact picker which allows the workflow enumerated in the steps above. I extracted it from the app and am making available in the hope that someone might find use for it.

The Contact Picker uses the new Fragments API in Android and supports Android API level 7 (Froyo) and above. The code for the contact picker is available on GitHub under an MIT licence. So feel free to get hacking and use it for your projects. One known issue is that the Contact Picker does not work well in landscape mode. There is a problem with switching the fragments for the different views in landscape mode. Send me a pull request on GitHub to fix it. 😉

For now, the Contact Picker only supports picking phone numbers, but can easily be extended to support email and other types of contact info. Hopefully I’ll get around to that sometime.

For now, for those who need only phone numbers, Happy hacking!

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • Digg
  • Facebook

Bring on the comments

  1. […] few days ago I pushed an update to the Android Contact Picker library on GitHub which has today been officially tagged in git as version 1.1. This update brings with it […]

Leave a Reply