WorkManager is the recommended solution for persistent work. Work is persistent when it remains scheduled through app restarts and system reboots. Because most background processing is best accomplished through persistent work, WorkManager is the primary recommended API for background processing.
Read More »Month: April 2022
Kotlin coroutines
A coroutine is a concurrency design pattern. Coroutines were added to Kotlin in version 1.3
Kotlin Coroutines are a powerful way to handle asynchronous programming in Kotlin.
On Android, coroutines help to manage long-running tasks that might block the main thread and cause your app to become unresponsive.
Lifecycles
Lifecycle-aware components perform actions in response to a change in the lifecycle status of another component, such as activities and fragments. These components help you produce better-organized, and often lighter-weight code, that is easier to maintain.
The androidx.lifecycle package provides classes and interfaces that let you build lifecycle-aware components—which are components that can automatically adjust their behavior based on the current lifecycle state of an activity or fragment, which avoid memory leaks or even application crashes.
LiveData
LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state, i.e., the STARTED or RESUMED state.
ViewModel
The ViewModel class is designed to store and manage UI-related data in a lifecycle-aware way. The ViewModel class allows data to survive configuration changes such as screen rotations.
Navigation
Android Jetpack’s Navigation component helps you implement navigation, from simple button clicks to more complex patterns, such as app bars and the navigation drawer.
The Navigation component consists of three key parts that are described below:
- Navigation graph: An XML resource that contains all navigation-related information in one centralized location. This includes all of the individual content areas within your app, called destinations, as well as the possible paths that a user can take through your app.
NavHost: An empty container that displays destinations from your navigation graph. The Navigation component contains a defaultNavHostimplementation,NavHostFragment, that displays fragment destinations.NavController: An object that manages app navigation within aNavHost. TheNavControllerorchestrates the swapping of destination content in theNavHostas users move throughout your app.