I'm helping put together this page: What is a context?
To help illustrate how components are related to a Context
, I created this diagram from looking through the framework source code:
After digging around a bit, I had the following questions:
- What creates a
Context
and what concrete classes are used? The baseContext
class itself is an abstract class, which requires almost all of its methods to be implemented. And aContextWrapper
, when instantiated, requires aContext
instance to be passed in as it's base context, so there must be at least one concreteContext
class. - I understand that the
ContextWrapper
and its subclasses utilize the wrapper/decorator pattern to add functionality to the baseContext
class as needed. What is the purpose of theContextThemeWrapper
? It overrides a few methods, but if it's wrapping a baseContext
, why not just delegate the calls to the baseContext
? For example, theActivity
class extendsContextThemeWrapper
, which provides a specific implementation forgetTheme()
andsetTheme()
. Why?
The Android developer java docs are a bit vague. E.g., ContextWrapper