通讯录封面图片设计,如何设计班级通讯录封面


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

Android Kotlin获取通讯录大头像或封面

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

简介代码

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"    }}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发表评论

登录后才能评论