Phone contact Android 2.1

in android 2.1, how can I read the contact image with the phone, if there is no contact image, I need to get the default that provides os.

+3
source share
1 answer

Just use the convenience method of the openContactPhotoInputStream () class ContactsContract.Contacts, which will return InputStreamcontaining the photo of the contacts, if any. If no photo is installed, it will return null , in which case you should try to set it android.R.drawable.ic_contact_pictureas the default image.

Right Having tried this on your own, it seems like you cannot access a closed Drawable, which is not even recommended. I am stupid.

However, you can simply go to your directory android-sdk/platforms/android-4/data/res/drawableand copy ic_contact_pictureto the drop-down catalog of projects. Then, if the above method returns null, just set what can be done as a photo.

+5
source

Source: https://habr.com/ru/post/1779123/


All Articles