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?
I ended up looking at some of the example code on Android Developer and found this project which detects the version of Android and uses a different class for accessing numbers depending on the Android version.
http://developer.android.com/resources/samples/BusinessCard/src/com/example/android/businesscard/index.html