Understanding Android Context

All our main screens now have their layouts defined. We will now explain Android Context since each screen we just created represents one Context instance. If you go through the class definition and follow class extension, you will realize that each activity we create extends the Context class.

Context represents the current state of the application or object. It is used to access specific classes and resources of the application. For example, consider the following lines of code:


Access we showed is provided by the Context class, which shows our activities are extending. Context is needed when we have to launch another activity, start ...

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.