是否可以使用ContactsContract获取用户经常与之交谈的联系人?
我知道我可以使用CallLog ContentProvIDer并尝试解决这个问题,但我想知道是否已经有办法实现它.
解决方法:
The number of times a contact has been contacted
ContactsContract.Contacts.times_contacted static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.disPLAY_name, ContactsContract.Contacts.STARRED, ContactsContract.Contacts.TIMES_CONTACTED, ContactsContract.Contacts.CONTACT_PRESENCE, ContactsContract.Contacts.PHOTO_ID, ContactsContract.Contacts.LOOKUP_KEY, ContactsContract.Contacts.HAS_PHONE_NUMBER, }; String name_to_search = "John Doe"; Cursor c = context.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, CONTACTS_SUMMARY_PROJECTION, null, null, ContactsContract.Contacts.TIMES_CONTACTED); context.startManagingCursor(c); if (c.movetoNext()) { String ID = c.getString(0); ArrayList<String> phones = new ArrayList<String>(); Cursor pCur = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", new String[]{ID}, null); while (pCur.movetoNext()) { phones.add(pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))); Log.i("", name_to_search+ " has the following phone number "+ pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))); } pCur.close(); }
总结 以上是内存溢出为你收集整理的android – 如何获取用户经常与之交谈的联系人?全部内容,希望文章能够帮你解决android – 如何获取用户经常与之交谈的联系人?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)