Summary
In this chapter, we understood what a lifecycle-aware component is and how we can create one.
We first explored how the lifecycle events and states are tied to Android components, such as Activity
or Fragment
, and then how predefined components from the Lifecycle
package can react to them. Then, we created and added a countdown timer component to the Repositories app.
Finally, we prevented users from cheating by making our timer component aware not only of the different lifecycle events and states of Activity
components but also of the lifecycle of composables.