Android 联系人列表
任何人都可以阐明如何从 android 获取联系人列表吗?
我只想获得与拨号器应用程序中相同的列表。但我使用下面的代码得到了很多不在拨号器列表中的联系人。
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(Contacts.People.CONTENT_URI, null, null, null, Contacts.ContactMethods.DEFAULT_SORT_ORDER);
startManagingCursor(cursor);
提前致谢。
Can anyone shed a light on how to get contact list from android?.
I just want to get the same list as in the dialer app. But im getting a lots of contacts that are not on the dialer list with the code below.
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(Contacts.People.CONTENT_URI, null, null, null, Contacts.ContactMethods.DEFAULT_SORT_ORDER);
startManagingCursor(cursor);
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
试试这个片段:
XML 文件是:
list_entry.xml
Try this snippet:
XML file is:
list_entry.xml
你所拥有的看起来不错。您能否详细说明“获取大量不在拨号列表中的联系人”?难道是Android在造人吗?或者您是否看到有电子邮件地址但没有电话号码的人(因此他们可能不会出现在拨号器中)?
请注意,
Contacts.People
适用于 Android 1.6 及更低版本。从 Android 2.0 开始,该提供程序已被弃用,并由ContactsContract
提供程序集取代。What you have seems fine. Could you elaborate on "getting a lots of contacts that are not on the dialer list"? Is it that Android is making up people? Or is it that you are seeing people with email addresses but no phone numbers (who therefore might not show up in the Dialer)?
Note that
Contacts.People
is for Android 1.6 and below. That provider is deprecated starting with Android 2.0, replaced by theContactsContract
set of providers.这是android联系人列表Activity的基本实现。
This is basic implementation of android contact list Activity.
嗯,首先谢谢你的回答。只是为了阐明这一点。
我只想接收手机上联系人的电子邮件。 “我的联系人”组。我看到这是 ContactList Activity 使用的组。
我完成了这样的事情:
首先查询组,然后查询电子邮件表。
Well, thanks for the answer first. Just to shed a light on this.
I just wanted to get emails only for the contacts on my phone. The "MyContacts" group. I saw this is the group ContactList Activity uses.
I finished doing somethig like this:
Just queried the group first and then the emails table.
尝试使用意图去联系人列表
try using intent to go to the contact list