Uri content:// can not be loaded.
See original GitHub issueHey, I have trouble with displaying pictures from gallery on Samsung Devices.
compile 'com.squareup.picasso:picasso:2.5.2'
However pictures of just taken photos form camera may be displayed (uri cames from camera)
1.Before all I give Application READ/WRITE_EXTERNAL_STORAGE permissions. 2.I create photo file using:
val mediaStorageDir = File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), "ApplicationFolder")
- and I return picture using MediaScannerConnectionClient that gives me Uri in form of content:// instead of file:// Logs
Created new uri:content://media/external/images/media/957
for file: file:///storage/emulated/0/Pictures/ApplicationFolder/someName_25.10.2017-12%3A11%3A48.jpg
- I receive Uri in onActivityResult
data.getData()
- Images from Camera are being displayed
Uri from camera either gallery:content://media/external/images/media/957
mImageView.post {
Picasso.with(mContext)
.load(mUri)
.placeholder(R.drawable.ic_loading_animated)
.fit()
.centerCrop()
.into(mImageView)
But images from Gallery are not.
Uri from camera either gallery:content://com.android.providers.media.documents/document/image%3A957
The only way to display them is to use
val inputStream = contentResolver.openInputStream(photoUri)
val bitmap = BitmapFactory.decodeStream(inputStream)
pv_preview_picture.setImageBitmap(bitmap)
then all pictures display well, but I don’t take adavantages of Picasso .fit() placeHolder() and so on and i disapointed of this solution
Summary: I don’t know where is the problem. It’s a problem of Piccasso, permission or Samsung. On my Nexus 6p i have no issue, but on Samsung i do.
UPDATE Finally I came accross two solution
taking bitmap from contentResolver.inputStream(uri) or imageView.setImageURI(uri)
but Picasso still not displaying pictures stackoverflow https://stackoverflow.com/questions/46930348/picasso-unable-to-display-image-from-gallery
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:6
Huawei honor 9 lite, android 9. 2021 and still having these problems 😕
Same issue with Huawei P30 Pro and Huawei Mate 40 Pro