I use zxing to encode a qr code and store it as a bitmap and then show it in ImageView
. Since the image generation time is significant I'm planning to move it to a separate thread (AsyncTaskLoader will be fine I think).
The problem is - it's an image and I know that to avoid memory leaks one should never store a strong reference to it in an Activity.
So how would you do it? How to cache an image to survive config changes (phone rotation) and generally avoid generating it onCreate()
?
Just point me in the right direction, please.
EDIT: Or maybe, if I use AsyncTaskLoader anyway, I should let it do its job and keep the Bitmap there? I mean, it's supposed to return the data it's loaded (generated in this case) and return it when needed, isn't it?