diff --git a/docs/notes/bugfix-22763.md b/docs/notes/bugfix-22763.md new file mode 100644 index 00000000000..f93573fb19d --- /dev/null +++ b/docs/notes/bugfix-22763.md @@ -0,0 +1 @@ +# Ensure mobilePickPhoto with width and height params works on older Android versions diff --git a/engine/src/java/com/runrev/android/Engine.java b/engine/src/java/com/runrev/android/Engine.java index 36363086ef9..57916e56c9b 100644 --- a/engine/src/java/com/runrev/android/Engine.java +++ b/engine/src/java/com/runrev/android/Engine.java @@ -2232,9 +2232,18 @@ else if (resultCode == Activity.RESULT_OK) float t_width = t_bitmap.getWidth(); float t_height = t_bitmap.getHeight(); - InputStream t_exif_in = ((LiveCodeActivity)getContext()).getContentResolver().openInputStream(t_photo_uri); - - ExifInterface t_exif = new ExifInterface(t_exif_in); + /* In API Level >= 24, you have to use an input stream to make sure that access + * to a photo in the library is granted. Before that you can just open the photo's + * file direct. */ + ExifInterface t_exif; + if (Build.VERSION.SDK_INT >= 24) + { + t_exif = new ExifInterface(t_in); + } + else + { + t_exif = new ExifInterface(t_photo_uri.getPath()); + } int t_orientation = t_exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);