Issue
Im my app, i use alot of getResources()
like that
BitmapFactory.decodeResource(getResources(), resourceid, opts);
i can use Resources res = getResources() as Global variable and use
BitmapFactory.decodeResource(res, resourceid, opts);
So, my question is: What's the better way to avoid memory leak?
Thanks
Solution
I do it this way on occasion which I think can be fine but you just have to watch it. In your situation, I'm not sure that its worth creating a Global
variable when nothing is changing. I will do it for a function to get a certain resource depending on context
or some other variable. But here, I don't see how
BitmapFactory.decodeResource(getResources(), resourceid, opts);
is any better than
BitmapFactory.decodeResource(res, resourceid, opts);
It seems that you are adding one extra unnecessary step
Answered By - codeMagic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.