I am picking a picture from gallery using code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setCont
The image you are trying to load is too large. That it causing the heap size to grow rapidly and filling it up, which is causing the app to crash. Try to downsize the image and then load it.
You can use the following code snippet:
public static Bitmap getResizedBitmap(Bitmap image, int newHeight, int newWidth) {
int width = image.getWidth();
int height = image.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(image, 0, 0, width, height,
matrix, false);
return resizedBitmap;
}