Selection of contacts with Android - only contacts with numbers?

I am writing an application that requires the user to select a contact from the contact list in order to send SMS to this contact. Can I request a contact list only for these contacts with a phone number (i.e. Not email addresses)? Currently, my code is as follows, but this shows all the contacts. Then I have to follow the logic in my activity in order to inform the user whether they have chosen a contact without an associated number and invited them to choose another.

Intent i = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);

Secondly, I understand that the contact API has changed from version 2.0 and therefore is it best to select contacts for all versions of Android OS? Am I right in assuming that the new contact API does not apply to pre 2.0?

+5
source share
2 answers

In the end, I looked through some Android Developer code examples and found this project that detects an Android version and uses a different class to access numbers depending on the Android version.

http://developer.android.com/resources/samples/BusinessCard/src/com/example/android/businesscard/index.html

-1
source
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.Phones.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT_RQCODE_OLD);

Shows phone numbers as well as contacts ... :)

+5
source

All Articles