
Kickstart Modern Android Development with Jetpack and Kotlin
By :

It's no secret by now that components within the Android framework have certain lifecycles that we must respect when we need to interact with them. The most common components that own a lifecycle are Activity
and Fragment
.
As programmers, we cannot control the lifecycle of Android components because their lifecycle is defined and controlled by the system or the way Android works.
Going back to Lifecycle components, a very good example is the entry point to our Android application, represented by the Activity
component, which, as we know, possesses a lifecycle. This means that in order to create a screen in our Android application, we need to create an Activity
component – from this point on, all our components must be aware of its lifecycle to not leak any memory.
Now, when we say that Activity
has a system-defined lifecycle, this actually translates into our Activity
class inheriting from ComponentActivity()
, which...