
public static voID getContactNumbers(Context context) { String contactNumber = null; int contactNumberType = Phone.TYPE_MOBILE; String nameOfContact = null; ContentResolver cr = context.getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null,null); if (cur.getCount() > 0) { while (cur.movetoNext()) { String ID = cur.getString(cur .getColumnIndex(BaseColumns._ID)); nameOfContact = cur .getString(cur .getColumnIndex(ContactsContract.Contacts.disPLAY_name)); if (Integer .parseInt(cur.getString(cur .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) { Cursor phones = cr .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",new String[] { ID },null); while (phones.movetoNext()) { contactNumber = phones.getString(phones .getColumnIndex(Phone.NUMBER)); contactNumberType = phones.getInt(phones .getColumnIndex(Phone.TYPE)); Log.i(TAG,"...Contact name ...." + nameOfContact + "...contact Number..." + contactNumber); ApplicationConstants.phoneContacts .add(new ContactNumberBean(nameOfContact,contactNumber,contactNumberType)); } phones.close(); } } }// end of contact name cursor cur.close(); } 如何实现ApplicationConstants和ContactNumberBean(nameOfContact,contactNumberType))这两个类?
解决方法 这是几乎相同问题的解决方案 – Answer希望能帮助到你 :)
总结以上是内存溢出为你收集整理的android – 从联系人处获取电子邮件,ID和电话(不使用活动)全部内容,希望文章能够帮你解决android – 从联系人处获取电子邮件,ID和电话(不使用活动)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)