Can someone clarify Android context references?

邮差的信 提交于 2019-12-01 19:31:31
theWook

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!