When to call activity context OR application context?

There has been a lot of posting about what these two contexts are.. But I’m still not getting it quite right

As I understand it so far:
Each is an instance of its class which means that some programmers recommend you to use this.getApplicationContext() as often as possible in order to not “leak” out any memory. This is because the other this (getting the Activity instance context) points to an Activity that is being destroyed each time the user tilts the phone or leave the app etc.. Which apparently the Garbage Collector (GC) doesn’t catch and therefore uses too much memory..

But can anyone please come up with some really good coding examples where it would be the right thing to use this (getting the context of the current Activity instance) and the application context will be useless/wrong?

7 Answers
7

Leave a Comment