Lifecycle-Aware Components in Android
Learn about lifecycle-aware components including what they are, how they work & how to create your own components and test them. By Sriyank Siddhartha.
Who is this for?
This course is designed for developers who already know the basics of Android app development using Kotlin and want to leverage the power of Android Jetpack by incorporating Lifecycle-Aware components into their apps.
- Lifecycles in Android
- Lifecycle-aware components
- Lifecycle observers
- Events and states
- Lifecycle owners
- Test a lifecycle-aware component
Part 1: Lifecycle-Aware Components in Android
Use Spoonacular API
Get a quick overview of the AwarenessFood app with setting up the API key from the Spoonacular API.
Explore what a lifecycle-aware component is, and understand what problem it solves in your app.
Create your first lifecycle-aware component and understand what exactly is a lifecycle owner and observer.
Explore how to make a lifecycle observer react to the lifecycle events of a lifecycle owner.
Explore when a lifecycle owner emits its lifecycle events to its observers.
Use Lifecycle States
State holds the current lifecycle state of the lifecycle owner. Explore how to execute code in a lifecycle observer when the lifecyle owner is at least in a certain lifecycle state.
Learn how to make a lifecycle-aware component react to the lifecycle changes of the Application class.
Explore how to create your own custom lifecycle owner by implementing LifecycleOwner interface and emit events to its observers.
Explore how to make a lifecycle-aware component subscribe to the lifecycle events of a custom lifecycle owner.
LiveData is an in-built lifecycle-aware component found in Android. Explore its significance and how to use it.
Explore how to use LiveData with a Fragment and update the UI.
Writing a test case is a crucial part of the development process. Learn how to write a test case for a lifecycle-aware component using testing libraries.