OutOfMemoryError - OOM allocating Bitmap with dimension

175 views Asked by At

I'm simply trying to load an image into an ImageView.

However, I'm getting this error on a Samsung Galaxy A02:

OOM allocating Bitmap with dimensions 960 x 1440

Why is it a sci-fi feature in 2023 to simply load an image into an ImageView in Android? This image is not particularly large neither. 960 x 1440 is approximately the size of a smartphone's screen these days.

Where should I continue with this? How can I make sure with a quick and easy method that my app won't crash by merely loading a single image into an ImageView?

Code is very simple:

  myImageView= findViewById(R.id.my_image_view);
            try {
                myImageView.setImageResource(R.drawable.background_picture);
            } catch (OutOfMemoryError e) {
                //lolz?
                e.printStackTrace();
            }

Thanks for all the help.

0

There are 0 answers