开发者

how do i get startActivityForResult() to bring up just a list of telephone contacts (like when i click on the "People" icon) using the android sdk?

excuse me if this question is obvious, but I am new to android sdk.

What I am trying to do is get a list of contacts that have real telephone numbers to send an sms message. I am deploying directly to my phone and trying to use just the contacts listed on my phone, but I am getting too many weird contacts. I would expect that when I call the startActivityForResult() method it will give me a list of phone contacts. What it seems to do is give me a list of all potential contacts and that seems to include twitter, facebook, and every potential email address I have sent to instead of just the contacts that are listed when I click on the "People" icon on my phone. The code I am using to call it is here:

private static final int PICK_CONTACT_REQUEST = 1;//defined elsewhere but listed for clarity

Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT_REQUEST);

The list that pops up starts off with hundreds o开发者_开发技巧f "Unnamed" contacts (many with icon photos that look to be twitter images), but also include what appear to be just email contacts, including what seems to be every craigslist email I may have ever sent to. Can anybody clear this up for me? how do I get just the "People" list without all the additional contact data?


There are several predifined actions with standard application contacts.

I think, what you're looking for is :

intent = new Intent(android.provider.Contacts.Intents.UI.LIST_CONTACTS_WITH_PHONES_ACTION);

Update: well this seems deprecated now, starting from API 5, one should use ContactsContract. I do not know this API though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜