tags:

views:

94

answers:

1

Hi

I 'm trying to read and display contacts from phone book in android. My Device is synced up with gmail and funambol which togehter have more than 600 records. Now by default my application reads gmail contacts. On selecting any contact from the displayed list, it throws an exception as the list is displaying a gmail contact which just has email and no phone no.

I need phone no to use in my application.

thanks

+1  A: 

Take a look at this answer here. It provides all the detail you need to get the contacts right.

The reason for the crash might be because you are trying to read the phone number when there is none, causing a NullPointerException. Maybe check if it's null before you try and use it, and if it is null then ask the user to pick again.

If this isn't right, feel free to provide more detail like code and logcat logs.

matto1990
Ya you are right. the code works fine.. But my phone book is synced with gmail. And this code displays the records from gmail account too along with my phone book's account .
success_anil
They are the same thing. Contacts is both combined. As far as I'm away there's no way to only get ones which aren't gmail. Maybe do some digging into the API of the new ContactsManager API. Not played with that yet
matto1990
Sure thanks for your answer.
success_anil
Well that was pretty simple.. Just need to invoke with proper content URI.. Thanks. Well I 've to select multiple contacts out of list. then do I 've to proceed using different way
success_anil