Android 获取联系人手机号码、姓名、地址、公司、邮箱、生日

 public void testGetAllContact() throws Throwable{//获取联系人信息的UriUri uri = ContactsContract.Contacts.CONTENT_URI;//获取ContentResolverContentResolver contentResolver = ContactListActivity.this.getContentResolver();//查询数据,返回CursorCursor cursor = contentResolver.query(uri, null, null, null, null);List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();while(cursor.moveToNext()){Map<String,Object> map = new HashMap<String,Object>();StringBuilder sb = new StringBuilder();//获取联系人的IDString contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));//获取联系人的姓名String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));//构造联系人信息sb.append("contactId=").append(contactId).append(",Name=").append(name);map.put("name", name);String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));//联系人ID //查询电话类型的数据操作Cursor phones = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,null, null);while(phones.moveToNext()){String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));//添加Phone的信息sb.append(",Phone=").append(phoneNumber);map.put("mobile", phoneNumber);}phones.close();//查询Email类型的数据操作Cursor emails = contentResolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,null,ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId,null, null);while (emails.moveToNext()){String emailAddress = emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));//添加Email的信息sb.append(",Email=").append(emailAddress);Log.e("emailAddress", emailAddress);map.put("email", emailAddress);}emails.close();//Log.i("=========ddddddddddd=====", sb.toString());//查询==地址==类型的数据操作.StructuredPostal.TYPE_WORKCursor address = contentResolver.query(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI,null,ContactsContract.CommonDataKinds.StructuredPostal.CONTACT_ID + " = " + contactId,null, null);while (address.moveToNext()){String workAddress = address.getString(address.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.DATA));//添加Email的信息sb.append(",address").append(workAddress);map.put("address", workAddress);}address.close();//Log.i("=========ddddddddddd=====", sb.toString());//查询==公司名字==类型的数据操作.Organization.COMPANY  ContactsContract.Data.CONTENT_URIString orgWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?"; String[] orgWhereParams = new String[]{id, ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE}; Cursor orgCur = contentResolver.query(ContactsContract.Data.CONTENT_URI, null, orgWhere, orgWhereParams, null); if (orgCur.moveToFirst()) { //组织名 (公司名字)String company = orgCur.getString(orgCur.getColumnIndex(ContactsContract.CommonDataKinds.Organization.DATA)); //职位 String title = orgCur.getString(orgCur.getColumnIndex(ContactsContract.CommonDataKinds.Organization.TITLE)); sb.append(",company").append(company);sb.append(",title").append(title);map.put("company", company);map.put("title", title);} orgCur.close(); list.add(map);Log.i("=========orgName=====", sb.toString());//查看所有的数据Log.e("=========map=====", map.toString());//有很多数据的时候,只会添加一条  例如邮箱,
        }Log.i("=========list=====", list.toString());//
        cursor.close();    }
复制代码

权限:

复制代码
    <!-- 读联系人权限 --><uses-permission android:name="android.permission.READ_CONTACTS" /><!-- 写联系人权限 --><uses-permission android:name="android.permission.WRITE_CONTACTS" /><!-- 拨号权限 --><uses-permission android:name="android.permission.CALL_PHONE" /><!-- 读短信权限 --><uses-permission android:name="android.permission.READ_SMS" />
复制代码

例子:

复制代码
package com.kelly.smsread;
import java.util.ArrayList;
import java.util.List;import org.json.JSONException;
import org.json.JSONObject;import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.Im;
import android.provider.ContactsContract.CommonDataKinds.Nickname;
import android.provider.ContactsContract.CommonDataKinds.Note;
import android.provider.ContactsContract.CommonDataKinds.Organization;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.util.Log;/** *  * @author larson * */  
public class ContactUtil {  public  List<Contacts> list;  private Context context;  private  JSONObject contactData;  private  JSONObject jsonObject;  public ContactUtil(Context context) {  this.context = context;  }  // ContactsContract.Contacts.CONTENT_URI= content://com.android.contacts/contacts;  // ContactsContract.Data.CONTENT_URI = content://com.android.contacts/data;  /** * 获取联系人信息,并把数据转换成json数据 *  * @return * @throws JSONException */  public String getContactInfo() throws JSONException {  list = new ArrayList<Contacts>();  contactData = new JSONObject();  String mimetype = "";  int oldrid = -1;  int contactId = -1;  // 1.查询通讯录所有联系人信息,通过id排序,我们看下android联系人的表就知道,所有的联系人的数据是由RAW_CONTACT_ID来索引开的  // 所以,先获取所有的人的RAW_CONTACT_ID  Uri uri = ContactsContract.Data.CONTENT_URI; // 联系人Uri;  Cursor cursor = context.getContentResolver().query(uri,  null, null, null, Data.RAW_CONTACT_ID);  int numm = 0;  while (cursor.moveToNext()) {  contactId = cursor.getInt(cursor  .getColumnIndex(Data.RAW_CONTACT_ID));  if (oldrid != contactId) {  jsonObject = new JSONObject();  contactData.put("contact" + numm, jsonObject);  numm++;  oldrid = contactId;  }  mimetype = cursor.getString(cursor.getColumnIndex(Data.MIMETYPE)); // 取得mimetype类型,扩展的数据都在这个类型里面  // 1.1,拿到联系人的各种名字  if (StructuredName.CONTENT_ITEM_TYPE.equals(mimetype)) {  cursor.getString(cursor  .getColumnIndex(StructuredName.DISPLAY_NAME));  String prefix = cursor.getString(cursor  .getColumnIndex(StructuredName.PREFIX));  jsonObject.put("prefix", prefix);  String firstName = cursor.getString(cursor  .getColumnIndex(StructuredName.FAMILY_NAME));  jsonObject.put("firstName", firstName);  String middleName = cursor.getString(cursor  .getColumnIndex(StructuredName.MIDDLE_NAME));  jsonObject.put("middleName", middleName);  String lastname = cursor.getString(cursor  .getColumnIndex(StructuredName.GIVEN_NAME));  jsonObject.put("lastname", lastname);  String suffix = cursor.getString(cursor  .getColumnIndex(StructuredName.SUFFIX));  jsonObject.put("suffix", suffix);  String phoneticFirstName = cursor.getString(cursor  .getColumnIndex(StructuredName.PHONETIC_FAMILY_NAME));  jsonObject.put("phoneticFirstName", phoneticFirstName);  String phoneticMiddleName = cursor.getString(cursor  .getColumnIndex(StructuredName.PHONETIC_MIDDLE_NAME));  jsonObject.put("phoneticMiddleName", phoneticMiddleName);  String phoneticLastName = cursor.getString(cursor  .getColumnIndex(StructuredName.PHONETIC_GIVEN_NAME));  jsonObject.put("phoneticLastName", phoneticLastName);  }  // 1.2 获取各种电话信息  if (Phone.CONTENT_ITEM_TYPE.equals(mimetype)) {  int phoneType = cursor  .getInt(cursor.getColumnIndex(Phone.TYPE)); // 手机  if (phoneType == Phone.TYPE_MOBILE) {  String mobile = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("mobile", mobile);  }  // 住宅电话  if (phoneType == Phone.TYPE_HOME) {  String homeNum = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("homeNum", homeNum);  }  // 单位电话  if (phoneType == Phone.TYPE_WORK) {  String jobNum = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("jobNum", jobNum);  }  // 单位传真  if (phoneType == Phone.TYPE_FAX_WORK) {  String workFax = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("workFax", workFax);  }  // 住宅传真  if (phoneType == Phone.TYPE_FAX_HOME) {  String homeFax = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("homeFax", homeFax);  } // 寻呼机  if (phoneType == Phone.TYPE_PAGER) {  String pager = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("pager", pager);  }  // 回拨号码  if (phoneType == Phone.TYPE_CALLBACK) {  String quickNum = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("quickNum", quickNum);  }  // 公司总机  if (phoneType == Phone.TYPE_COMPANY_MAIN) {  String jobTel = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("jobTel", jobTel);  }  // 车载电话  if (phoneType == Phone.TYPE_CAR) {  String carNum = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("carNum", carNum);  } // ISDN  if (phoneType == Phone.TYPE_ISDN) {  String isdn = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("isdn", isdn);  } // 总机  if (phoneType == Phone.TYPE_MAIN) {  String tel = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("tel", tel);  }  // 无线装置  if (phoneType == Phone.TYPE_RADIO) {  String wirelessDev = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("wirelessDev", wirelessDev);  } // 电报  if (phoneType == Phone.TYPE_TELEX) {  String telegram = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("telegram", telegram);  }  // TTY_TDD  if (phoneType == Phone.TYPE_TTY_TDD) {  String tty_tdd = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("tty_tdd", tty_tdd);  }  // 单位手机  if (phoneType == Phone.TYPE_WORK_MOBILE) {  String jobMobile = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("jobMobile", jobMobile);  }  // 单位寻呼机  if (phoneType == Phone.TYPE_WORK_PAGER) {  String jobPager = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("jobPager", jobPager);  } // 助理  if (phoneType == Phone.TYPE_ASSISTANT) {  String assistantNum = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("assistantNum", assistantNum);  } // 彩信  if (phoneType == Phone.TYPE_MMS) {  String mms = cursor.getString(cursor  .getColumnIndex(Phone.NUMBER));  jsonObject.put("mms", mms);  }  String mobileEmail = cursor.getString(cursor  .getColumnIndex(Email.DATA));  jsonObject.put("mobileEmail", mobileEmail);  }  }  // 查找event地址  if (Event.CONTENT_ITEM_TYPE.equals(mimetype)) { // 取出时间类型  int eventType = cursor.getInt(cursor.getColumnIndex(Event.TYPE)); // 生日  if (eventType == Event.TYPE_BIRTHDAY) {  String birthday = cursor.getString(cursor  .getColumnIndex(Event.START_DATE));  jsonObject.put("birthday", birthday);  }  // 周年纪念日  if (eventType == Event.TYPE_ANNIVERSARY) {  String anniversary = cursor.getString(cursor  .getColumnIndex(Event.START_DATE));  jsonObject.put("anniversary", anniversary);  }  }  // 获取即时通讯消息  if (Im.CONTENT_ITEM_TYPE.equals(mimetype)) { // 取出即时消息类型  int protocal = cursor.getInt(cursor.getColumnIndex(Im.PROTOCOL));  if (Im.TYPE_CUSTOM == protocal) {  String workMsg = cursor.getString(cursor  .getColumnIndex(Im.DATA));  jsonObject.put("workMsg", workMsg);  } else if (Im.PROTOCOL_MSN == protocal) {  String workMsg = cursor.getString(cursor  .getColumnIndex(Im.DATA));  jsonObject.put("workMsg", workMsg);  }  if (Im.PROTOCOL_QQ == protocal) {  String instantsMsg = cursor.getString(cursor  .getColumnIndex(Im.DATA));  jsonObject.put("instantsMsg", instantsMsg);  }  }  // 获取备注信息  if (Note.CONTENT_ITEM_TYPE.equals(mimetype)) {  String remark = cursor.getString(cursor.getColumnIndex(Note.NOTE));  jsonObject.put("remark", remark);  }  // 获取昵称信息  if (Nickname.CONTENT_ITEM_TYPE.equals(mimetype)) {  String nickName = cursor.getString(cursor  .getColumnIndex(Nickname.NAME));  jsonObject.put("nickName", nickName);  }  // 获取组织信息  if (Organization.CONTENT_ITEM_TYPE.equals(mimetype)) { // 取出组织类型  int orgType = cursor.getInt(cursor  .getColumnIndex(Organization.TYPE)); // 单位  if (orgType == Organization.TYPE_CUSTOM) { // if (orgType ==  // Organization.TYPE_WORK)  // {  String company = cursor.getString(cursor  .getColumnIndex(Organization.COMPANY));  jsonObject.put("company", company);  String jobTitle = cursor.getString(cursor  .getColumnIndex(Organization.TITLE));  jsonObject.put("jobTitle", jobTitle);  String department = cursor.getString(cursor  .getColumnIndex(Organization.DEPARTMENT));  jsonObject.put("department", department);  }  }  // 获取网站信息  if (Website.CONTENT_ITEM_TYPE.equals(mimetype)) { // 取出组织类型  int webType = cursor.getInt(cursor.getColumnIndex(Website.TYPE)); // 主页  if (webType == Website.TYPE_CUSTOM) {  String home = cursor.getString(cursor  .getColumnIndex(Website.URL));  jsonObject.put("home", home);  } // 主页  else if (webType == Website.TYPE_HOME) {  String home = cursor.getString(cursor  .getColumnIndex(Website.URL));  jsonObject.put("home", home);  }  // 个人主页  if (webType == Website.TYPE_HOMEPAGE) {  String homePage = cursor.getString(cursor  .getColumnIndex(Website.URL));  jsonObject.put("homePage", homePage);  }  // 工作主页  if (webType == Website.TYPE_WORK) {  String workPage = cursor.getString(cursor  .getColumnIndex(Website.URL));  jsonObject.put("workPage", workPage);  }  }  // 查找通讯地址  if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)) { // 取出邮件类型  int postalType = cursor.getInt(cursor  .getColumnIndex(StructuredPostal.TYPE)); // 单位通讯地址  if (postalType == StructuredPostal.TYPE_WORK) {  String street = cursor.getString(cursor  .getColumnIndex(StructuredPostal.STREET));  jsonObject.put("street", street);  String ciry = cursor.getString(cursor  .getColumnIndex(StructuredPostal.CITY));  jsonObject.put("ciry", ciry);  String box = cursor.getString(cursor  .getColumnIndex(StructuredPostal.POBOX));  jsonObject.put("box", box);  String area = cursor.getString(cursor  .getColumnIndex(StructuredPostal.NEIGHBORHOOD));  jsonObject.put("area", area);  String state = cursor.getString(cursor  .getColumnIndex(StructuredPostal.REGION));  jsonObject.put("state", state);  String zip = cursor.getString(cursor  .getColumnIndex(StructuredPostal.POSTCODE));  jsonObject.put("zip", zip);  String country = cursor.getString(cursor  .getColumnIndex(StructuredPostal.COUNTRY));  jsonObject.put("country", country);  }  // 住宅通讯地址  if (postalType == StructuredPostal.TYPE_HOME) {  String homeStreet = cursor.getString(cursor  .getColumnIndex(StructuredPostal.STREET));  jsonObject.put("homeStreet", homeStreet);  String homeCity = cursor.getString(cursor  .getColumnIndex(StructuredPostal.CITY));  jsonObject.put("homeCity", homeCity);  String homeBox = cursor.getString(cursor  .getColumnIndex(StructuredPostal.POBOX));  jsonObject.put("homeBox", homeBox);  String homeArea = cursor.getString(cursor  .getColumnIndex(StructuredPostal.NEIGHBORHOOD));  jsonObject.put("homeArea", homeArea);  String homeState = cursor.getString(cursor  .getColumnIndex(StructuredPostal.REGION));  jsonObject.put("homeState", homeState);  String homeZip = cursor.getString(cursor  .getColumnIndex(StructuredPostal.POSTCODE));  jsonObject.put("homeZip", homeZip);  String homeCountry = cursor.getString(cursor  .getColumnIndex(StructuredPostal.COUNTRY));  jsonObject.put("homeCountry", homeCountry);  }  // 其他通讯地址  if (postalType == StructuredPostal.TYPE_OTHER) {  String otherStreet = cursor.getString(cursor  .getColumnIndex(StructuredPostal.STREET));  jsonObject.put("otherStreet", otherStreet);  String otherCity = cursor.getString(cursor  .getColumnIndex(StructuredPostal.CITY));  jsonObject.put("otherCity", otherCity);  String otherBox = cursor.getString(cursor  .getColumnIndex(StructuredPostal.POBOX));  jsonObject.put("otherBox", otherBox);  String otherArea = cursor.getString(cursor  .getColumnIndex(StructuredPostal.NEIGHBORHOOD));  jsonObject.put("otherArea", otherArea);  String otherState = cursor.getString(cursor  .getColumnIndex(StructuredPostal.REGION));  jsonObject.put("otherState", otherState);  String otherZip = cursor.getString(cursor  .getColumnIndex(StructuredPostal.POSTCODE));  jsonObject.put("otherZip", otherZip);  String otherCountry = cursor.getString(cursor  .getColumnIndex(StructuredPostal.COUNTRY));  jsonObject.put("otherCountry", otherCountry);  }  }  cursor.close();  Log.i("contactData", contactData.toString());  return contactData.toString();  }}  
复制代码

import cn.ihope.mozyhome.domain.Contacts; http://blog.csdn.net/yemh111/article/details/7171349

直接可以运行的   记得要加配置文件

复制代码
package com.kelly.smsread;import org.json.JSONException;
import org.json.JSONObject;import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.Im;
import android.provider.ContactsContract.CommonDataKinds.Nickname;
import android.provider.ContactsContract.CommonDataKinds.Note;
import android.provider.ContactsContract.CommonDataKinds.Organization;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
import android.provider.ContactsContract.Data;
import android.util.Log;public class MainActivity extends Activity {private static final String TAG = "MainActivity";private JSONObject contactData;private JSONObject jsonObject;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);try {getContactInfo();} catch (JSONException e) {// TODO Auto-generated catch block
            e.printStackTrace();}}public String getContactInfo() throws JSONException {// 获得通讯录信息 ,URI是ContactsContract.Contacts.CONTENT_URI
contactData = new JSONObject();String mimetype = "";int oldrid = -1;int contactId = -1;Cursor cursor = getContentResolver().query(Data.CONTENT_URI,null, null, null, Data.RAW_CONTACT_ID);int numm=0;while (cursor.moveToNext()) {contactId = cursor.getInt(cursor.getColumnIndex(Data.RAW_CONTACT_ID)); if (oldrid != contactId) {jsonObject = new JSONObject();contactData.put("contact" + numm, jsonObject);numm++;oldrid = contactId;}// 取得mimetype类型mimetype = cursor.getString(cursor.getColumnIndex(Data.MIMETYPE));// 获得通讯录中每个联系人的ID// 获得通讯录中联系人的名字if (StructuredName.CONTENT_ITEM_TYPE.equals(mimetype)) {//            String display_name = cursor.getString(cursor.getColumnIndex(StructuredName.DISPLAY_NAME));String prefix = cursor.getString(cursor.getColumnIndex(StructuredName.PREFIX));jsonObject.put("prefix", prefix);String firstName = cursor.getString(cursor.getColumnIndex(StructuredName.FAMILY_NAME));jsonObject.put("firstName", firstName);String middleName = cursor.getString(cursor.getColumnIndex(StructuredName.MIDDLE_NAME));jsonObject.put("middleName", middleName);String lastname = cursor.getString(cursor.getColumnIndex(StructuredName.GIVEN_NAME));jsonObject.put("lastname", lastname);String suffix = cursor.getString(cursor.getColumnIndex(StructuredName.SUFFIX));jsonObject.put("suffix", suffix);String phoneticFirstName = cursor.getString(cursor.getColumnIndex(StructuredName.PHONETIC_FAMILY_NAME));jsonObject.put("phoneticFirstName", phoneticFirstName);String phoneticMiddleName = cursor.getString(cursor.getColumnIndex(StructuredName.PHONETIC_MIDDLE_NAME));jsonObject.put("phoneticMiddleName", phoneticMiddleName);String phoneticLastName = cursor.getString(cursor.getColumnIndex(StructuredName.PHONETIC_GIVEN_NAME));jsonObject.put("phoneticLastName", phoneticLastName);}// 获取电话信息if (Phone.CONTENT_ITEM_TYPE.equals(mimetype)) {// 取出电话类型int phoneType = cursor.getInt(cursor.getColumnIndex(Phone.TYPE));// 手机if (phoneType == Phone.TYPE_MOBILE) {String mobile = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("mobile", mobile);}// 住宅电话if (phoneType == Phone.TYPE_HOME) {String homeNum = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("homeNum", homeNum);}// 单位电话if (phoneType == Phone.TYPE_WORK) {String jobNum = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("jobNum", jobNum);}// 单位传真if (phoneType == Phone.TYPE_FAX_WORK) {String workFax = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("workFax", workFax);}// 住宅传真if (phoneType == Phone.TYPE_FAX_HOME) {String homeFax = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("homeFax", homeFax);}// 寻呼机if (phoneType == Phone.TYPE_PAGER) {String pager = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("pager", pager);}// 回拨号码if (phoneType == Phone.TYPE_CALLBACK) {String quickNum = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("quickNum", quickNum);}// 公司总机if (phoneType == Phone.TYPE_COMPANY_MAIN) {String jobTel = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("jobTel", jobTel);}// 车载电话if (phoneType == Phone.TYPE_CAR) {String carNum = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("carNum", carNum);}// ISDNif (phoneType == Phone.TYPE_ISDN) {String isdn = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("isdn", isdn);}// 总机if (phoneType == Phone.TYPE_MAIN) {String tel = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("tel", tel);}// 无线装置if (phoneType == Phone.TYPE_RADIO) {String wirelessDev = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("wirelessDev", wirelessDev);}// 电报if (phoneType == Phone.TYPE_TELEX) {String telegram = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("telegram", telegram);}// TTY_TDDif (phoneType == Phone.TYPE_TTY_TDD) {String tty_tdd = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("tty_tdd", tty_tdd);}// 单位手机if (phoneType == Phone.TYPE_WORK_MOBILE) {String jobMobile = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("jobMobile", jobMobile);}// 单位寻呼机if (phoneType == Phone.TYPE_WORK_PAGER) {String jobPager = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("jobPager", jobPager);}// 助理if (phoneType == Phone.TYPE_ASSISTANT) {String assistantNum = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("assistantNum", assistantNum);}// 彩信if (phoneType == Phone.TYPE_MMS) {String mms = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));jsonObject.put("mms", mms);}}// }// 查找email地址if (Email.CONTENT_ITEM_TYPE.equals(mimetype)) {// 取出邮件类型int emailType = cursor.getInt(cursor.getColumnIndex(Email.TYPE));// 住宅邮件地址if (emailType == Email.TYPE_CUSTOM) {String homeEmail = cursor.getString(cursor.getColumnIndex(Email.DATA));jsonObject.put("homeEmail", homeEmail);}// 住宅邮件地址else if (emailType == Email.TYPE_HOME) {String homeEmail = cursor.getString(cursor.getColumnIndex(Email.DATA));jsonObject.put("homeEmail", homeEmail);}// 单位邮件地址if (emailType == Email.TYPE_CUSTOM) {String jobEmail = cursor.getString(cursor.getColumnIndex(Email.DATA));jsonObject.put("jobEmail", jobEmail);}// 单位邮件地址else if (emailType == Email.TYPE_WORK) {String jobEmail = cursor.getString(cursor.getColumnIndex(Email.DATA));jsonObject.put("jobEmail", jobEmail);}// 手机邮件地址if (emailType == Email.TYPE_CUSTOM) {String mobileEmail = cursor.getString(cursor.getColumnIndex(Email.DATA));jsonObject.put("mobileEmail", mobileEmail);}// 手机邮件地址else if (emailType == Email.TYPE_MOBILE) {String mobileEmail = cursor.getString(cursor.getColumnIndex(Email.DATA));jsonObject.put("mobileEmail", mobileEmail);}}// 查找event地址if (Event.CONTENT_ITEM_TYPE.equals(mimetype)) {// 取出时间类型int eventType = cursor.getInt(cursor.getColumnIndex(Event.TYPE));// 生日if (eventType == Event.TYPE_BIRTHDAY) {String birthday = cursor.getString(cursor.getColumnIndex(Event.START_DATE));jsonObject.put("birthday", birthday);}// 周年纪念日if (eventType == Event.TYPE_ANNIVERSARY) {String anniversary = cursor.getString(cursor.getColumnIndex(Event.START_DATE));jsonObject.put("anniversary", anniversary);}}// 即时消息if (Im.CONTENT_ITEM_TYPE.equals(mimetype)) {// 取出即时消息类型int protocal = cursor.getInt(cursor.getColumnIndex(Im.PROTOCOL));if (Im.TYPE_CUSTOM == protocal) {String workMsg = cursor.getString(cursor.getColumnIndex(Im.DATA));jsonObject.put("workMsg", workMsg);}else if (Im.PROTOCOL_MSN == protocal) {String workMsg = cursor.getString(cursor.getColumnIndex(Im.DATA));jsonObject.put("workMsg", workMsg);}if (Im.PROTOCOL_QQ == protocal) {String instantsMsg = cursor.getString(cursor.getColumnIndex(Im.DATA));jsonObject.put("instantsMsg", instantsMsg);}}// 获取备注信息if (Note.CONTENT_ITEM_TYPE.equals(mimetype)) {String remark = cursor.getString(cursor.getColumnIndex(Note.NOTE));jsonObject.put("remark", remark);}// 获取昵称信息if (Nickname.CONTENT_ITEM_TYPE.equals(mimetype)) {String nickName = cursor.getString(cursor.getColumnIndex(Nickname.NAME));jsonObject.put("nickName", nickName);}// 获取组织信息if (Organization.CONTENT_ITEM_TYPE.equals(mimetype)) {// 取出组织类型int orgType = cursor.getInt(cursor.getColumnIndex(Organization.TYPE));// 单位if (orgType == Organization.TYPE_CUSTOM) {//             if (orgType == Organization.TYPE_WORK) {String company = cursor.getString(cursor.getColumnIndex(Organization.COMPANY));jsonObject.put("company", company);String jobTitle = cursor.getString(cursor.getColumnIndex(Organization.TITLE));jsonObject.put("jobTitle", jobTitle);String department = cursor.getString(cursor.getColumnIndex(Organization.DEPARTMENT));jsonObject.put("department", department);}}// 获取网站信息if (Website.CONTENT_ITEM_TYPE.equals(mimetype)) {// 取出组织类型int webType = cursor.getInt(cursor.getColumnIndex(Website.TYPE));// 主页if (webType == Website.TYPE_CUSTOM) {String home = cursor.getString(cursor.getColumnIndex(Website.URL));jsonObject.put("home", home);}// 主页else if (webType == Website.TYPE_HOME) {String home = cursor.getString(cursor.getColumnIndex(Website.URL));jsonObject.put("home", home);}// 个人主页if (webType == Website.TYPE_HOMEPAGE) {String homePage = cursor.getString(cursor.getColumnIndex(Website.URL));jsonObject.put("homePage", homePage);}// 工作主页if (webType == Website.TYPE_WORK) {String workPage = cursor.getString(cursor.getColumnIndex(Website.URL));jsonObject.put("workPage", workPage);}}// 查找通讯地址if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)) {// 取出邮件类型int postalType = cursor.getInt(cursor.getColumnIndex(StructuredPostal.TYPE));// 单位通讯地址if (postalType == StructuredPostal.TYPE_WORK) {String street = cursor.getString(cursor.getColumnIndex(StructuredPostal.STREET));jsonObject.put("street", street);String ciry = cursor.getString(cursor.getColumnIndex(StructuredPostal.CITY));jsonObject.put("ciry", ciry);String box = cursor.getString(cursor.getColumnIndex(StructuredPostal.POBOX));jsonObject.put("box", box);String area = cursor.getString(cursor.getColumnIndex(StructuredPostal.NEIGHBORHOOD));jsonObject.put("area", area);String state = cursor.getString(cursor.getColumnIndex(StructuredPostal.REGION));jsonObject.put("state", state);String zip = cursor.getString(cursor.getColumnIndex(StructuredPostal.POSTCODE));jsonObject.put("zip", zip);String country = cursor.getString(cursor.getColumnIndex(StructuredPostal.COUNTRY));jsonObject.put("country", country);}// 住宅通讯地址if (postalType == StructuredPostal.TYPE_HOME) {String homeStreet = cursor.getString(cursor.getColumnIndex(StructuredPostal.STREET));jsonObject.put("homeStreet", homeStreet);String homeCity = cursor.getString(cursor.getColumnIndex(StructuredPostal.CITY));jsonObject.put("homeCity", homeCity);String homeBox = cursor.getString(cursor.getColumnIndex(StructuredPostal.POBOX));jsonObject.put("homeBox", homeBox);String homeArea = cursor.getString(cursor.getColumnIndex(StructuredPostal.NEIGHBORHOOD));jsonObject.put("homeArea", homeArea);String homeState = cursor.getString(cursor.getColumnIndex(StructuredPostal.REGION));jsonObject.put("homeState", homeState);String homeZip = cursor.getString(cursor.getColumnIndex(StructuredPostal.POSTCODE));jsonObject.put("homeZip", homeZip);String homeCountry = cursor.getString(cursor.getColumnIndex(StructuredPostal.COUNTRY));jsonObject.put("homeCountry", homeCountry);}// 其他通讯地址if (postalType == StructuredPostal.TYPE_OTHER) {String otherStreet = cursor.getString(cursor.getColumnIndex(StructuredPostal.STREET));jsonObject.put("otherStreet", otherStreet);String otherCity = cursor.getString(cursor.getColumnIndex(StructuredPostal.CITY));jsonObject.put("otherCity", otherCity);String otherBox = cursor.getString(cursor.getColumnIndex(StructuredPostal.POBOX));jsonObject.put("otherBox", otherBox);String otherArea = cursor.getString(cursor.getColumnIndex(StructuredPostal.NEIGHBORHOOD));jsonObject.put("otherArea", otherArea);String otherState = cursor.getString(cursor.getColumnIndex(StructuredPostal.REGION));jsonObject.put("otherState", otherState);String otherZip = cursor.getString(cursor.getColumnIndex(StructuredPostal.POSTCODE));jsonObject.put("otherZip", otherZip);String otherCountry = cursor.getString(cursor.getColumnIndex(StructuredPostal.COUNTRY));jsonObject.put("otherCountry", otherCountry);}}}cursor.close();Log.i("contactData", contactData.toString());return contactData.toString();}

}

注意 : 本文由 微信妈妈(买卖公众号ontaobao.cn) 编辑整理, 转载地址 http://www.cnblogs.com/zhujiabin/p/6645551.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/73039.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ContactsContract.Contacts.CONTENT_URI无法获取手机号码

需求&#xff1a;打开系统联系人&#xff0c;获取手机号码。 可能会遇到的问题&#xff1a;同一个用户多个手机号码 阅读本文会收获2个技能&#xff1a; 学会反编译Apk查看代码实现原理快速定位反编译后的代码 最开始我以为像类似获取系统图片那样去获取手机号码&#xff0…

Android登陆注册的手机号码匹配

1、背景介绍 在做开发的时候&#xff0c;经常会有一些应用&#xff0c;需要用户的手机号码注册使用&#xff0c;避免任意输入一个不是手机号码的11位数字注册&#xff0c;会使用正则表达式匹配。但是在网上找了很多匹配表达式&#xff0c;发现漏了一些&#xff0c;经过查找&…

红楼梦人物关系简图

贾家&#xff0c;宁国公与荣国公之后&#xff0c;为钟鼎勋贵之家。王家&#xff0c;都太尉统制县伯王公之后&#xff0c;为军官将领之家。薛家&#xff0c;皇商。皇室任命&#xff0c;为皇宫搜罗海外奇珍异宝的皇商。史家&#xff0c;保龄侯尚书令史公之后&#xff0c;为文臣名…

关于红楼梦Python文本分析

1. 获取小说文本 读取文件 # 获取小说文本 # 读取文件 fn open("prepare\\红楼梦_曹雪芹.txt", encoding"utf-8") string_data fn.read() # 读出整个文件 fn.close() # 关闭文件 2.对文本进行处理 # 文本预处理 pattern re.compile(u\t|\n|\.|-…

Google BERT 中文应用之《红楼梦》中对话人物提取

​点击上方“迈微AI研习社”&#xff0c;选择“星标★”公众号 转载自&#xff1a;PaperWeekly 庞龙刚 之前看到过一篇文章&#xff0c;通过提取文章中对话的人物&#xff0c;分析人物之间的关系&#xff0c;很好奇如何通过编程的方式知道一句话是谁说的。但是遍搜网络没有发现…

【知识图谱】构建红楼梦知识图谱

在b站看到有人用知识图谱构建红楼梦的人物关系的知识图谱&#xff0c;跟着做了一遍&#xff0c;在这里记录。 1、安装neo4j 具体见&#xff1a;https://blog.csdn.net/Zhouzi_heng/article/details/110948997 2、为python安装py2neo4j py2neo是一个社区第三方库&#xff0c…

数据驱动的未来城市八大趋势

来源&#xff1a;微信公众号腾讯研究院 趋势一 更可持续 城市的发展要为整个人类文明的永续传承和为后人能享受到更高质量的生活为目标。一个更加智慧的城市&#xff0c;势必具有着更加可持续发展的能力。新科技为城市的核心系统的设施提供了更为智能、高效率的调配方案&#x…

城市计算,交通预测,流量预测,需求预测汇总

本项目汇集了新基建和城市计算等领域的最新研究成果&#xff0c;包括白皮书、学术论文、人工智能实验室和城市数据集等相关内容。 This project is a collection of recent research in areas such as new infrastructure and urban computing, including white papers, acade…

未来城市技术v2.0

ibrand shadow 你理想中的工作、生活状态是怎么样的&#xff1f; 理想工作&#xff1a;一天只需工作2小时&#xff0c;其他时间自由安排&#xff1a;研究、实验、学习、休息… 人生方向是探索出来的 shadow eva 这种状态我也很喜欢???? &#xff0c;all 你们呢&#xff1f;…

预见2021:《2021年中国呼叫中心产业全景图谱》 未来十年八大预测

预见2021&#xff1a;《2021年中国呼叫中心产业全景图谱》 未来十年八大预测 按业务划分来看&#xff0c;呼叫中心的业务大类归到了BPO(商务流程外包)当中。呼叫中心具有高附加值、低碳经济、提高城市服务业水平、创造大量就业机会等优点。 呼叫中心产业全景图 呼叫中心是为了…

大数据时代已经来临 分析未来十年发展趋势

今天的大数据分析市场与几年前的市场截然不同&#xff0c;正是由于海量数据的暴增&#xff0c;未来十年&#xff0c;全球各行各业都将发生变革、创新和颠覆。   未来十年大数据分析的发展趋势 公有云优于私有云的优势继续扩大。公有云正逐步成为客户群的首选大数据分析平台。…

大数据预测未来趋势

数据是近年来备受关注的一门技术&#xff0c;大数据技术的战略意义不在于掌握庞大的数据信息&#xff0c;而在于对这些含有意义的数据进行专业化处理。 换而言之&#xff0c;如果把大数据比作一种产业&#xff0c;那么这种产业实现盈利的关键&#xff0c;在于提高对数据的“加工…

2022年智慧城市趋势的12个预测

随着人们继续适应过去一年带来的巨大变化&#xff0c;行业参与者分享了他们对城市发展的预期。 城市需要适应2021年的巨大挑战。除了持续且不断变化的COVID大流行之外&#xff0c;人们还面临着越来越危险的驾驶行为&#xff0c;极端天气事件&#xff0c;紧张的政治气候和不断上…

海外观察丨未来 10 大科技趋势预测全解读(上)

编者按 近年来&#xff0c;世界正经历百年未有之大变局&#xff0c;国际局势深刻演变&#xff0c;世界多极化和经济全球化在曲折中继续发展。 新冠疫情起伏反复&#xff0c;人们比任何时候都期盼依靠科学技术战胜疫情&#xff0c;依靠科技创新来推动经济复苏。随着 5G 进入商…

2023 年数据中心四大发展趋势预测

随着数据中心市场将在 2023 年继续扩张&#xff0c;一些人预测到 2032 年将增长 7.5%&#xff0c;市场价值将达到 2000 亿美元&#xff0c;数据中心在我们城市和社区高效运行中的普及也可能会扩大&#xff0c;同时它们对环境的影响也会扩大。 随着我们进入新的一年&#xff0c;…

2023看得见的未来:数据中心行业十大发展趋势

数据中心建设和消纳在不断创历史新高的同时&#xff0c;也正在遭受不少的抨击&#xff0c;因为它们消耗大量的电力和水、排放温室气体、产生垃圾填埋场的垃圾&#xff0c;却不产生有形的产品——如汽车、房屋和钢铁。 但其实我们的生产生活中&#xff0c;无论是视频流、在线购物…

[英语阅读]小布什获评《NME》杂志年度恶棍

Oasis, Muse, George W. Bush pick up NME awards 英国流行音乐杂志《NME》&#xff08;New Music Express&#xff09;周三评选出绿洲乐队为最佳英国乐队&#xff0c;而美国前总统小布什则破纪录地第六次被评选为年度恶棍。缪斯(Muse)乐队击败英国的绿洲乐队和美国的莱昂国王…

最初计算机发明家英文介绍,求助~一篇80字的电脑发展史,英语的~

满意答案 scorpiot7j8 2013.11.04 采纳率&#xff1a;53% 等级&#xff1a;12 已帮助&#xff1a;8757人 你可以略作筛选 Milestones in Computer Development WEBLIOGRAPHY AND CREDITS 2000 B.C. The abacus is first used for computations. 1642 A.D. Blaise Pascal cre…

怎样做一个好的PPT演讲

文章目录 一、做好PPT演讲的重要性二、怎么做好PPT演讲1.做一个好的PPT2.做好演讲 三、分析一些比较好的PPT演讲视频四、实例解析和总结 一、做好PPT演讲的重要性 不管是在学生时期的竞赛展示&#xff0c;毕业答辩&#xff0c;我们都需要进行PPT演讲&#xff1b;工作之后&…

谈谈演讲 - 优秀的演讲都是准备出来的

和任何技能一样&#xff0c;演讲的技能&#xff0c;也需要通过不断实战积累&#xff0c;一步步升级你的演讲技能点。我觉得&#xff0c;演讲能力的升级线路&#xff0c;大体是这样的&#xff1a; 0.演讲完全依赖临场发挥 1.意识到“优秀的演讲都是准备出来的” 2.演讲内容的策划…