Resizing images failing on start, setContentView & bitmap factory[android]

79 views Asked by At
java.lang.OutOfMemoryError
        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)           
          at nis.animation_door.Page5.onCreate(Page5.java:32)

Basically it tries to rescale/resize background images i m using.

  • the images have 1024x768 size
  • I use SonyXperia tablet z(real display size - 1920x1128px)

Following similar question answered on SO I have put all background images into drawable-hdpi,ldpi etc folders

At runtime, Android resize's images based on need (based on the screen size and resolution). It uses Bitmap's for doing the resizing internally. Which, obviously, is very memory intensive (kinda allocates memory like crazy). One quick way to fix such issues can be, that you copy all drawable files to drawable-ldpi, mdpi, hdpi folders. This way android will just pick up the files from these folders and not resize them.

This did not help, I suspect because even if you put same images into ldpi folder, you have to resize/rescale them manually.

My question - if make my bkg images exactly same size as my real device - 1920x1128, will it help? any other suggestions?

0

There are 0 answers