BitmapFactory: Unable to decode stream: java.io.FileNotFoundException even when file IS actually there

Replace mImageUri.toString() with mImageUri.getPath().

decodeFile expects a path, not an uri string.


file:///storage/emulated/0/cameratest/picture459838058.jpg

Remove file:// because the decodeFile() expects a file system path.

/storage/emulated/0/cameratest/picture459838058.jpg

Use BitmapFactory.decodeStream instead of BitmapFactory.decodeFile.

try ( InputStream is = new URL( file_url ).openStream() ) {
  Bitmap bitmap = BitmapFactory.decodeStream( is );
}

Source https://stackoverflow.com/a/28395036/5714364

Tags:

Java

Android