Android Context 101 with Class Diagram
Beginner’s Guide to understand the fundamental of Context with class diagram in Android app development
4 min readApr 29, 2023
You may find Context
in Android app development is confusing. For example, which one you should use?
Before answering that, let’s look at the Context
class diagram below to understand its relationship with other classes/components.
Context Class Diagram
From the class diagram above, you can tell Activity
, Service
and Application
inherits/extends Context
indirectly.
As you can see, there are ContextThemeWrapper
that extends ContextWrapper
that extends Context
. Here are the brief descriptions of all 3 classes.
Context
is an abstract class that allows an Android application to access system resources and interact with the operating systemContextWrapper
is a convenient way to modify the behavior of a Context object, such as adding additional functionality or overriding existing behavior, without changing the original Context itself.ContextThemeWrapper
…