下面是论坛上有人写的关于获取Contact Number的code,非常详细,供参考。
String[] projection = new String[] {
People._ID,
People.NAME,
People.NUMBER,
};
// Get the base URI for People table in Contacts content provider.
// which is: content://contacts/people/
Uri contactUri = People.CONTENT_URI;
// Best way to retrieve a query; returns a managed query.
Cursor peopleCursor = managedQuery (contactUri,
projection, //Which columns to return.
null, // WHERE clause--we won't specify.
null, // Selection Args??
People.DEFAULT_SORT_ORDER); // Order-by name
// go to the beginning of the list
peopleCursor.moveToFirst();
// So, here we have a contact. We need to get the contact ID (_id) then
// build the Uri to get the phones section of that user's record
// which is a subdirectory of a contact record
long personId = peopleCursor.getLong(peopleCursor.getColumnIndex("_id"));
Uri personUri = ContentUris.withAppendedId(contactUri, personId );
// So now the URL looks like: content://contacts/people/_id(where the actual id of the record is here)
Uri phoneUri=
Uri.withAppendedPath(personUri, Contacts.People.Phones.CONTENT_DIRECTORY);
// Now the URL looks like: content://contacts/people/_id/phones (where phones is literally "phones")
// Now get all the phone numbers for this contact
Cursor phonesCursor = managedQuery(phoneUri,
null,
null,
null,
Phones.DEFAULT_SORT_ORDER);
// We now have a cursor for all the phone numbers for that User ID
// go to the beginning of the phone list.
phonesCursor.moveToFirst();
分享到:
相关推荐
android平台,获取联系人资料——Provider.Contact的使用
Android 8.0 系统自带 Contact Android 8.0 系统自带 Contact Android 8.0 系统自带 Contact
安卓android ContactManager联系人管理器
android-通讯录源码,有读写通讯录的完整源码示例,做相关开发的朋友可以参考一下
一个实现通讯录功能的android应用小程序。功能不是很完善,欢迎下载修改。
android源码 联络人的备份和恢复功能 采用Vcard存储
Facebook Contact Sync is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the...
android通讯录,可以实现基本的添加,短信,电话功能
e-contact-android E-contact app helps citizens of Dnipro and neighboring regions to solve problems citizens have in their everyday lives by providing a reliable channel of communication with local ...
Android源码开发之Contact分享
Android应用程序联系人CONTACT源码, 可供相关设计人员参考
Contact Selector 联系人选择器,选择联系人,Choose Contact,Contact,Contact select
android android android
Android开发程序 用虚拟机或安卓手机运行编写的程序
ApduSenderContact - Android software Introduction: Requirements: Android USB on the Go phone License: distributed under GPL version 3 (http://www.gnu.org/licenses/gpl.html)
Android-ContactManager 安卓联系人管理器
摘要:Java源码,Android源码,通讯录 Android contact通讯录实例,比较不错的例子,来自书中的完整实例,Android手机读取联系人信息、显示、保存、编辑联系人,多卡同时读取联系人等,涉及要点:删除指定数据列、URI...
本文章总结了一段Android获取通话时间程序代码,有需要的朋友可参考一下。 我们知道安卓系统中通话时长应该是归Callog管,所以建议去查查ContactProvider,或者是TelephonyProvider Service测试 可以的通话开始的...
android 上sim卡联系人的存取,framework层代码分析。在实现sim卡联系人的基础上,添加usim卡的附加字段存取
android快速滑动列表 首字母提示contactlist