I'm writing an application that requires the user to choose a contact from the contact list in order to send an SMS to that contact. Is there any way I can query the contact list for just those contacts with a phone number (i.e. not the ones with just e-mail addresses)? Currently my code looks like the following, but this shows all contacts - I then have to do the logic in my activity to inform the user if they've chosen a contact with no associated number and prompt them to choose another.
Intent i = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
A second thing, I realise the contact API changed from 2.0 onwards so what is the best practise for choosing contacts to cover all versions of the Android OS? Am I right in assuming the new contact API doesn't relate to pre 2.0?
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.Phones.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT_RQCODE_OLD);
Shows the Phone Numbers aswell as the Contacts... :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With