question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uri content:// can not be loaded.

See original GitHub issue

Hey, 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")
  1. 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
  1. I receive Uri in onActivityResult data.getData()
  2. 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:open
  • Created 6 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

2reactions
deva56commented, Feb 20, 2021

Huawei honor 9 lite, android 9. 2021 and still having these problems 😕

0reactions
martppacommented, May 26, 2021

Same issue with Huawei P30 Pro and Huawei Mate 40 Pro

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content for the URI cannot be loaded. The URI may be invalid
You could do just this: var hb = new HyperlinkButton { Content = fooText, ClickMode = ClickMode.Release, NavigateUri = new Uri(fooLink.
Read more >
Content for the URI cannot be loaded. The URI may be invalid ...
When trying to instantiate a domain context I get Code: 4004 System.ArgumentException: Content for the URI cannot be loaded. The URI may be...
Read more >
URI not loaded from content:// · Issue #772 · coil-kt/coil - GitHub
Describe the bug Coil not load image from URI with content:// Expected behavior As it comes from documentation URI from content should work....
Read more >
Timeseries data cannot be generated...The URI is invalid or ...
The Agent Error message is the following: Timeseries data cannot be generated due to the following agent error: The URI is invalid or...
Read more >
How to Fix the 'Preview Could Not Be Loaded' Error - Elementor
If you receive the error message “the preview could not be loaded”, try the following: · Enable Safe Mode. · Make sure the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found