Recently in the Context of two subclasses of the Context is not very understand, why use ContextImpl class to implement the Context, rather than directly using ContextWrapper?
Context is the abstract class, which acts as an interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.
See Context class code here
ContextWrapper is an Adapter or proxying implementation of Context that simply delegates all of its calls to another Context. Can be subclassed to modify behavior without changing the original Context. [It uses adapter pattern]
See ContextWrapper class code here
ContextImpl is a common implementation of Context API, which provides the base context object for Activity and other application components.
See ContextImpl class code here
So if you browse through the code of above three classes, you can easily understand the abstract class Context class declares the API methods, ContextImpl implements those API methods, whereas ContextWrapper class is just an adapter of any Context type so it can be used at various places where adapter pattern is required rather than using Context child classes.
Hope it reduces confusion!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With