If you are able to call view.getContext() to return the Activity’s context under which the view instance is currently being rendered, why do some of the View family methods take a Context as a parameter?
Could this not be implicit, or are there occassions when getContext() is different from a Context passed to one of these methods?
Here is an example: http://developer.android.com/reference/android/widget/ViewAnimator.html#setInAnimation(android.content.Context, int)
Many thanks for clearing this up
view.getContext()actually return’s your Activity‘s context, not application’s. That is the reason you need to provide such context when initializing a new View.And there’s a difference between these two contexts. An Activity’s context is attached to that particular activity’s life-cycle. However, the application’s context is referring to application’s life-cycle.
For more info, read this.