What is Context?

Read about Context in Android

Amandeep Singh
1 min readOct 14, 2023
Photo by Pathum Danthanarayana on Unsplash

Literal meaning of context

The circumstances that form the setting for an event, statement, or and idea and in terms of which it can be fully understood.

The Context tells us about the surrounding information

It is very important to understand the environment which we wnat to understand

We can break Context and its uses into three major parts

  1. It allows us to access resources
  2. It allows us to interact with other Android components by sending messages
  3. It gives you information about your app environment

Types of Context(Only important one)

  1. Application Context
  2. Activity Context

Application Context

# Tied to the lifecycle of the application

# This is Singleton Instance

# Load resource value

# Start and Bind to the Service

# Send a Broadcast

# Register Broadcast receiver

Activity Context

# Tied to the lifecycle of the Activity

The benefit of using “ContextWrapper” is that it lets you to modify behaviour without changing the original context

--

--

Amandeep Singh

👓 Software Engineer | 📚 Lifelong Learner | 🧩 Problem Solver | 🔧 Process Engineer | 🏗️ App Architect | ☕ Java Junkie