I know why OutOfMemoryError Exception occurs.But there are any best way to convert byte array to Bitmap.And I used below code ,But when large byte it force close app and gives OutOfMemoryError Exception.
And i have API it just return me byte array nothing else.
Bitmap bmp = BitmapFactory.decodeByteArray(bytearray, 0, bytearray.length);
Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapbytes , 0, bitmapbytes .length);
Returns The decoded bitmap, or null if the image could not be decode.
Here is what worked for me: photo is a string of an image by the way.
byte[] imgbytes = Base64.decode(photo, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(imgbytes, 0,
imgbytes.length);
imageupload.setImageBitmap(bitmap);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With