Can Someone Clarify Android Context References?
My misunderstanding continues ... Can anyone cite references for the proper use of get*Context()? I get conflicting recommendations about using getBaseContext(), getApplicationCon
Solution 1:
http://android-developers.blogspot.co.uk/2009/01/avoiding-memory-leaks.html
Read this article. It describe why we should use getApplicationContext()
rather than Activity's this
This is summary of the article:
In summary, to avoid context-related memory leaks, remember the following:
- Do not keep long-lived references to a context-activity (a reference to an activity should have the same life cycle as the activity itself)
- Try using the context-application instead of a context-activity
Post a Comment for "Can Someone Clarify Android Context References?"