0

I was saving image Uri to SQLite as String which I picked from gallery and it was set as image to my ImageView. But from 2nd activity I'm taking the Image(Uri) as String and converting to Uri and setting to ImageView.

When I run the 2nd activity it is giving an error like

resolveUri failed on bad bitmap uri: content://com.miui.gallery.open/raw/06.jpg

The code is like.

String valueImage;

imageView.setImageURI(Uri.parse(valueImage));

Do I need to convert in another way?

Thank you.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

1

You can use Glide. It's very easy and takes only one line.

String valueImage; // Get url fro SQLite

Glide
     .With(this)
     .Load(Uri.parse(valueImage))
     .Apply(RequestOptions.CircleCropTransform()).Into(imageView);

The import statement is to put into the app module gradle file (app/build.gradle)

implementation 'com.github.bumptech.glide:glide:4.9.0'

Hope it helps !

Maxouille
  • 2,729
  • 2
  • 19
  • 42
  • You don't need to. The `Load()` method from Glide take care of it by itself ! That's why it's so easy to use :) – Maxouille Feb 15 '19 at 12:31
  • And you need to import Glide into your project. I edited my post with the import statement. – Maxouille Feb 15 '19 at 12:31
  • java.io.FileNotFoundException: /content:/com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20190209_162806.jpg (No such file or directory) – Jamaldin Sabirjanov Feb 15 '19 at 13:01
  • Can you post the value of your `valueImage` ? – Maxouille Feb 15 '19 at 13:13
  • content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20190209_162806.jpg – Jamaldin Sabirjanov Feb 15 '19 at 13:16
  • java.lang.SecurityException: Permission Denial: opening provider com.miui.gallery.provider.GalleryOpenProvider from ProcessRecord{554b889 14152:com.silkway.test/u0a176} (pid=14152, uid=10176) that is not exported from UID 10032 – Jamaldin Sabirjanov Feb 15 '19 at 13:50
  • Check this, you have to ask permission to read the gallery : https://stackoverflow.com/a/34722591/3780625 – Maxouille Feb 15 '19 at 13:53
  • W/Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored – Jamaldin Sabirjanov Feb 15 '19 at 14:30
  • It's a setup problem, check here : http://sjudd.github.io/glide/doc/download-setup.html#gradle – Maxouille Feb 15 '19 at 15:31
0

Try Glide for your requirement

Import glide using gradle

implementation 'com.github.bumptech.glide:glide:4.8.0'

Then set image to imageview using this method

Glide.with(context)
                .load(Uri.fromFile(new File(valueImage)))
                .into(imageView);
Quick learner
  • 10,632
  • 4
  • 45
  • 55