Exception : OutOfMemoryError

前端 未结 7 815
北海茫月
北海茫月 2020-11-29 13:49

I have published my app in play store. Now In Crashes and ANRs I am getting following errors on 2 devices (Galaxy Note3 and Galaxy Note II). I dont know how to solve these e

相关标签:
7条回答
  • 2020-11-29 14:46

    If you have high resolution image , you should scale them down to avoid different devices to load the image without facing a memory problem. In your case, some phones may not exhibit the same behavior on the first run, but eventually, without handling an optimized image loading solution, app will crash.

    Check more on the "memory problem":

    Topic under Load a Scaled Down Version into Memory.
    http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
    Out of memory error on Android

    On how to avoid them:
    How to avoid an out of memory error while using bitmaps in Android

    For an overview:
    http://blogs.innovationm.com/android-out-of-memory-error-causes-solution-and-best-practices/ http://android-developers.blogspot.de/2009/01/avoiding-memory-leaks.html

    Before setting a drawable as the background for your imageview, i.e.:

    iv.setBackgroundResource(R.drawable.buddha4);  
    

    as @rup35h suggested in the answer, get a scaled bitmap or try other options like inSampleSize, do check how your solution affects the quality of your image too.

    0 讨论(0)
提交回复
热议问题