OOM - Samsung galaxy GT-I9300 Android 4.3
See original GitHub issueGreat Library, Working really well except this OOM issue on the device above It can be fixed but the problem is inside PickerDialog.kt the function takePhoto at line:452 is private so It cant overridden. Normally I deal with this by using method to tweak the bitmap before rotating which should fix this issue (Java) `{
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inDither = true;
Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
ExifInterface exif = new ExifInterface(file.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
Matrix matrix = new Matrix();
if (orientation == 6) {
matrix.postRotate(90);
}
else if (orientation == 3) {
matrix.postRotate(180);
}
else if (orientation == 8) {
matrix.postRotate(270);
}
myBitmap = Bitmap.createBitmap(myBitmap, 0, 0, myBitmap.getWidth(), myBitmap.getHeight(), matrix, true); // rotating bitmap
imageView.setImageBitmap(myBitmap);
} catch (Exception ex) {
ex.printStackTrace();
}
}`
And here is Stacktrace
03-29 15:01:32.110 11420-11420/com.go.app.dev E/AndroidRuntime: FATAL EXCEPTION: main java.lang.OutOfMemoryError at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:726) at android.graphics.Bitmap.createBitmap(Bitmap.java:703) at android.graphics.Bitmap.createBitmap(Bitmap.java:636) at com.robertlevonyan.components.picker.ExtensionsKt.rotate(Extensions.kt:76) at com.robertlevonyan.components.picker.PickerDialog.takePhoto(PickerDialog.kt:462) at com.robertlevonyan.components.picker.PickerDialog.onActivityResult(PickerDialog.kt:444) at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:156) at android.app.Activity.dispatchActivityResult(Activity.java:5563) at android.app.ActivityThread.deliverResults(ActivityThread.java:3496) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3543) at android.app.ActivityThread.access$1200(ActivityThread.java:159) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) at dalvik.system.NativeStart.main(Native Method)
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Working correctly now, Thank you
?