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.
It is nice example of inheritance-over-composition approach, where you add logic to your component instead of subclassing it to just override some methods.
However, AndroidX Lifecycle is not specific towards components and has unified set of callbacks. If you need to listen to, say, specific methods of DialogFragment, you are out of luck and need to implement this yourself.
Unreadable RxJava error stacktrace is a known problem. Chances are you also faced cryptic crash log from your QA team and was scratching your head for hours before finding solution or even abandoning said crash altogether.
Relevant discussion on RxJava Github.
This article is intended for both Java and Android devs. Part of snippets are currently in Kotlin, I am in process of migrating it to Java (to be compatible with both worlds). Ignore code irrelevant for your platform.
Clean Architecture is current standard in Android development.
At its core is dependency rule: inner layers do not interact with outer layers.
For instance, you have domain layer (library) with entity BankAccount. This layershould be platform-agnostic.
In Android we use Kotlin, and data class is a natural choice for it. Now we may need to store this entity in database with ORM (like Room) or Realm. First one requires adding bunch of annotations on existing data class, second one requires extending RealmObject. Both approaches make your domain layer non-portable and dependent on platform (outer layer) thus violating Dependency Rule.
Google’s Jetpack initiative is truly amazing. Throughout past several years it made tremendous progress, which will be culminated by stable release of Jetpack Compose.
Yet there are sometimes gaps, obscure parts in their libraries.
Recently I had to implement dynamic navigation, i.e. first app screen is selected based on some logic inside Activity’s onCreate.
As application is screen-based, Jetpack Navigation is a natural choice.
For static nav graph, you simply set navigation xml in NavHostFragment.
For dynamic nav graph, you need to set navigation xml manually.
During course in Inertial Nav Systems I tried to implement sample sensor calibration on Android. It appeared that Android already applies online calibration, and starting from certain API it is possible to obtain this calibration separately from raw output (previously it was reported as single value).
First, let’s clear what our sensor model look like:
Now, let’s clear what calibration actually means. For sensors two types of calibration exist: factory and online. Factory calibration is done one time once sensor is manufactured and is hardwired into sensor memory. Online calibration is done while sensor is operating and supplied separately.