In this article we will find out how to write a
ViewPager composable in Jetpack Compose. Here’s what we want our composable to offer:
In this article we’ll find out how to add biometric authentication to an Android app developed with Jetpack Compose. As not all devices offer biometric authentication, we will also add a PIN fallback in case no biometric options are available, or if the user prefers to use PIN.
Let’s first describe what we want our app to do:
In Jetpack Compose composables accept a
Modifier that alters the appearance or behaviour of the composable they are applied to. Some of the modifiers, like
padding are common to all composable functions while others can only be applied to specific composables, like
weight for Row and Column, In this article we will see how to create a composable function with its own modifier attribute.
What we want to achieve is the following
We want to create a composable that takes a set of pairs of children, one being a label and the other being the description. We…
Recent versions of Android offer both Light and Dark themes, which the user can set globally via the device settings. Most apps nowadays follow this setting and change their theme based on the global setting, but it is also good practice to offer users an app option to set the theme regardless of what the global setting is. In this article we’ll find out how to do that with Jetpack Compose.
The first thing we need to do is persist the user setting; we will use
SharedPreferences for this, though you may want to consider using the new DataStore —…
In the Android View system it is common to have ViewModels observe lifecycle events, generated by the Fragment or Activity hosting them, in order to start and stop certain tasks. Typically ViewModels will implement the DefaultLifecycleObserver interface and listen for lifecycle events like onStart and onStop. We can see an example below
This is all pretty straightforward — the Fragment adds the ViewModel as an observer on its lifecycle, and the ViewModel overrides the lifecycle events it is interested in. In this case, we want to run a task when the fragment is started (say, fetch some data from…
One of the most common tasks developers need to implement is the display of a heterogeneous list of items, for instance a list of weather cards separated by a header for each of the days, as shown below
While this is not a particularly difficult problem to solve thanks to Android’s Recyclerview this can become rather tedious when we have different view types to display. As a result of this several libraries have been available for a while now that aim to simplify and automate much of this wok, like Epoxy, Groupie and others.
To visualize the differences between Android’s…
Android has been out for over a dozen years now, and how we write applications for Android has changed over the years. From the host of architectural solutions that have been proposed over the years, MVP (Model View Presenter), MVVM (Model View, ViewModel) and more recently MVI (Model View Intent) are the most notable ones. With the release of the Android Architecture components at Google IO 2017 the spotlight was on MVVM and that’s been the preferred architecture until recently.
With the recently release of JetPack Compose Beta and the required mental shift on how we write apps for compose…
Senior Android Developer