What is difference between
getContext(), when I say
this I mean
this within an
In general there are two type of classes. Ones that extend
ContextWrapper class (
Application) and those that do not extend it (like
If class extends
ContextWrapperthen you can use
Context. Such classes normally do not have
Those classes that do not extend
ContextWrapperbut still save and use
getContext()function. And you cannot use
Contextin such cases.
And these two cases are mutually exclusive. At least I don’t recall classes that extend
ContextWrapper and have
getContext at the same time.
getContext() is not defined in an Activity. It’s used in a
View subclass) to get a reference to the enclosing context (an Activity).
There is no difference. When you are in an Activity, getContext() will return this. This is because an Activity is a context!