I have an activity that set a background image. And it causes OutOfMemory in some devices when I keep enter and leave this activity.
-
Suppose I am using x-hdpi device. Is that I would use up more memory if I put a image in hdpi bucket than put in x-hdpi bucket because the image need to be scaled up if I put in hdpi bucket? Actually, how to determine which bucket should I put the image to?
-
And Is there any way to avoid OutOfMemory of this case?
I try to call recycle and setImageResource(null) in OnDestroy. But when I enter that activity again, I would have exception “cannot draw recycled bitmap”.
Answer to Second Question.
Before Decoding image and setting to background you should resize image to Avoid Memory Overflow Error. This Error generally comes when we load image inside Memory. See how to Display Images Efficiently
Answer to First Question.
Putting same image to different folder will not cost memory as if you show LDPI image to HDPI device it will stretch but will take the same memory(All though it will look weired). But if your designer make Image differently for each density then image size will differ then it will take some more or less memory