如何设计班级通讯录封面 通讯录获取头像有什么好方法_今日关注


(资料图片仅供参考)

关 于通讯录封面图片设计,如何设计班级通讯录封面 的知识大家了解吗?以下就是小编整理的关于通讯录封面图片设计,如何设计班级通讯录封面 的介绍,希望可以给到大家一些参考,一起来了解下吧!

这几天做个老人桌面,那些系统自带的通讯录,通讯录列表头像太小了,老人看不清。于是自己写一个老人专用通讯录,给联系人设置大头贴,还能语言报名,这样老人就很好找到需要打电话的联系人!

至于通讯录获取头像,网上有很多方法,但是都太乱了!

简介代码

ContentResolver cr = view.getContext().getContentResolver();Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,Long.parseLong(contact.contact_id));InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);Bitmap photo = BitmapFactory.decodeStream(input);

加载到自己的ImageView

Glide.with(context)    .load(Uri.parse(item.photo_uri))    .into(R.id.iv_photo))

怎么获取通讯录数据

val uri = ContactsContract.CommonDataKinds.Contactables.CONTENT_URIval PHONE_BOOK_LABEL = "phonebook_label";contactList = ArrayList<ContactBean>()val cursor = contentResolver.query(    uri,    arrayOf(        ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,        ContactsContract.CommonDataKinds.Phone.NUMBER,        ContactsContract.CommonDataKinds.Phone.CONTACT_ID,        ContactsContract.CommonDataKinds.Phone.PHOTO_FILE_ID,        ContactsContract.CommonDataKinds.Phone.PHOTO_ID,        ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI,        ContactsContract.CommonDataKinds.Phone.PHOTO_URI,        PHONE_BOOK_LABEL    ),    null,    null,    ContactsContract.CommonDataKinds.Phone.SORT_KEY_PRIMARY)if (null != cursor) {    while (cursor.moveToNext()) {        val firstChar =            cursor.getString(cursor.getColumnIndex(PHONE_BOOK_LABEL))        val contact_id =            cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID))        val name =            cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME))        val phoneNum =            cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))        val photo_id =            cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_ID))        val photo_file_id =            cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_FILE_ID))        val photo_uri =            cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI))        val photo_thumbnail_uri =           cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI))        val contact = ContactBean(            firstChar,            contact_id,            name,            phoneNum,            photo_id,            photo_file_id,            photo_uri,            photo_thumbnail_uri        )        contactList!!.add(contact)    }    cursor.close()

自定义的通讯录实体类:

data class ContactBean(    val firstChar: String? = "",    val contact_id: String? = "",    val name: String? = "",    val phoneNum: String? = "",    val photo_id: String? = "",    val photo_file_id: String? = "",    val photo_uri: String? = "",    val photo_thumbnail_uri: String? = "") {    override fun toString(): String {        return "${firstChar},${name},${contact_id},${phoneNum},${photo_id},${photo_file_id},${photo_uri},${photo_thumbnail_uri}n"    }}
推荐DIY文章
网速为什么不稳定 可能是电脑后台流量网络应用过多导致
电脑突然没声音怎么办?原因及处理方法全面整理给大家
打开Excel提示“Excel词典(XLLEX.DLL)文件丢失或损坏” 可以怎么解决
电脑设置360安全防护中心启用蓝屏修复功能 有需要的朋友可以参考一下
微信聊天记录删了怎么恢复找回来 记住先将电脑版微信设置为保存聊天记录
【全球热闻】windows10光盘映像下载 方便快捷的下载欢迎大家安装体验
精彩新闻

超前放送