tags:

views:

1019

answers:

2

I want the user to select a contact to which my application would send a SMS. How do I ensure that when I start an activity with ACTION_PICK intent only those contacts with mobile phone numbers are displayed?

Currently, I'm starting the activity like this:

Intent intent = new Intent(Intent.ACTION_PICK, Phones.CONTENT_URI);
+1  A: 

I suspect it is not possible. You would need a separate Uri, one that the Phones content provider used to restrict the output to mobile phones only. I do not see that such a Uri exists.

You can still have an activity pick only users with phone numbers, but you will have to write the activity yourself, using a managedQuery().

CommonsWare
I was thinking it could be something to do with CONTENT_FILTER_URI. Any idea what that is used for?
Prashast
That looks like it is for use with getting the contact for a specific phone number -- see http://almondmendoza.com/2009/01/30/getting-the-contact-info-when-on-a-number/
CommonsWare
A: 

Reading the code, it looks like you can specify the UI.LIST_CONTACTS_WITH_PHONES_ACTION action in the intent to show only contacts with phone numbers. I haven't tried this out though. Also, this action has the same effect as the contact setting "Only contacts with phones"

dhaag23
Isn't that undocumented - not part of the SDK?
Prashast