Android obtains the contact avatar instance code according to the phone number

In the daily use of Android phones, it is a common problem to obtain contact avatars according to phone numbers. This article describes the implementation code of Android to obtain the contact avatar according to the phone number in the form of an example. Share with you for your reference. The specific methods are as follows:

First, through the ContentProvider, you can access data such as contacts in Android. Common URIs are:

Contact information URI: content://com.android.contacts/contacts Contact phone URI: content://com.android.contacts/data/phones Contact mail URI: content://com.android.contacts/data/emails

It also provides the function of obtaining data table data according to phone number. The method is: data / phones / filter / number, and return a data set. Then get the contact of the contact through the dataset_ ID, according to contact_ ID open the InputStream of the avatar picture, and finally use bitmapfactory. Decodestream() to obtain the avatar of the contact.

The specific function codes are as follows:

I hope this article will be helpful to your Android program design.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>