Skip to main content

10 Best Things for Android Development in 2020

2020 is a crazy year for all of us, for sure. In this article, I tried to remember what happened in 2020 in Android development and came up with these 10 main things. #6 is the important one.

                                         Refer - https://vladsonkin.com/ 


#1 View Binding

View Binding makes our work with views easier, and it brings advantages over the standard findViewById() and other alternative solutions. View Binding generates a binding class for each XML layout, and the instance contains references to all the views with the ID.

Column 1ButterKnifeKotlin SyntheticsData BindingfindViewByIdView Binding
Fast❌ *✅❌ *✅✅
Null-safe❌❌✅❌✅
Compile-time safe❌❌✅✅ **✅

View Binding takes the best parts of the other solutions and avoids their drawbacks. And it’s more important now since the popular Kotlin Synthetics are deprecated in Kotlin 1.4.

#2 StateFlow and SharedFlow

Kotlin Flow is a stream of data that can be computed asynchronously. For example, we can make a network request with the Flow and then handle it without blocking the main thread.

Kotlin Flow

The Flow has been there for a while, but recently in Kotlin 1.4, we had a significant improvement – StateFlow and SharedFlow. In a few words, they provide us state management and effectively replace the ConflatedBroadcastChannel and BroadcastChannel (they are deprecated).

No need to use RxJava or channels because the Flow can cover everything. More than that, some blogs already advise replacing the LiveData with the StateFlow/SharedFlow.

#3 MotionLayout

MotionLayout is a new animation tool, and it’s a part of ConstraintLayout 2.0. With MotionLayout, you can animate pretty much everything: 

MotionLayout Android

We can move elements, rotate, fade, scale them, and even animate custom attributes. In addition to that, starting with Android Studio 4.0, we have a special editor for the MotionLayout. With this, we can create animations easier and preview them.

To learn more about MotionLayout, check the codelab and samples on GitHub.

#4 Hilt

Hilt now is a new recommended DI for Android from Google. If you used a Dagger in your project, then you know how much boilerplate you need to write and how the overall architecture is complicated.

That’s precisely why the Hilt was introduced, to simplify the structure and make the DI setup an easy thing thanks to a standard set of components and scopes.

The Hilt is also well integrated with the Jetpack Components: ViewModel, Navigation, WorkManager. Use the @ViewModelInject annotation in the ViewModel object’s constructor, annotate the SavedStateHandle dependency with @Assisted, and you’re set. No more Factory is needed:

Copy

Check out this official guide for more information and try it in the codelab.

#5 Jetpack Datastore

Android DataStore is a new way of storing the data, and it aims to replace the SharedPreferences. Jetpack DataStore is built on top of Kotlin Coroutines and Flow, and it allows us to store the data in key-value pairs (the same as SharedPreferences) or typed objects (backed by Protocol Buffers). 

It brings great benefits over the “old” SharedPreferences, namely:

  • Async API for storing and reading the data (Flow)
  • Type-safety out of the box (Protocol Buffers)
  • Safe to call from UI thread (Dispatchers.IO underneath)

And many other perks, such as transactional API, which guarantee consistency. Jetpack DataStore is an official recommendation, and the migration from the SharedPreferences is an easy one with 3 steps.

#6 Jetpack Compose

We all know that Jetpack Compose is the most significant trend of 2020 and upcoming years. This library is a new way to create UI, which replaces the current one with XML layouts and Views. Jetpack Compose mainly has 2 benefits:

Declarative paradigm 

The declarative approach simplifies work with the views and decreases the possible errors by regenerating the entire screen from scratch. Do you want to update an element? Then you need to update the state and composite the screen again. And don’t worry about performance; Compose will only update the element that needs to be changed. No need to manually change the view hierarchy.

jetpack compose declarative ui

Standalone library

Jetpack Compose doesn’t rely on an operation system, and because of it has great flexibility. Now the UI is not tied to the Android OS version, and the users can receive the latest features/updates no matter what Android version they have.

Less XML and more Kotlin. How cool is that ðŸ™‚ 

Jetpack Compose is still in alpha and not ready for production. But you already can make your hands dirty by following the official tutorial, and playing with the great samples on GitHub.

Another great news is that recently Jetpack Compose became available for the desktopNow you can share your UI with the Android apps. And you can share your business logic too with the help of Kotlin Multiplatform.

#7 Kotlin Multiplatform

Kotlin Multiplatform Mobile gives us the ability to write the business logic once in Kotlin and then reuse it in Android and iOS apps. Beautiful idea, we create the module with the business logic and then use it in our mobile apps. 

kotlin multiplatform

What I especially like is that introducing the Kotlin Multiplatform to our projects is a low-risk. We can start step by step by creating a small feature first and then reuse it.

It’s also quite different from cross-platform; we just share the business logic and leave the UI work for the native apps. However, if we use the Jetpack Compose for UI, we can already have a desktop and Android app by reusing almost the whole codebase.

You can play with Kotlin multiplatform in this tutorial.

#8 Android 11

Next is  Android 11 is out there. 

android 11

This version was mostly about privacy and introduced such features as Scoped Storage, Package Visibility, and other enhancements.

Check out this article on how to prepare your app for Android 11.


#9 Firebase Firestore

Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.



#10 CameraX Features

CameraX is a Jetpack support library, built to help you make camera app development easier. It provides a consistent and easy-to-use API surface that works across most Android devices, with backward-compatibility to Android 5.0 (API level 21).

Thanks for reading, Please hit like if you see these :) Happy new year. Happy Coding.

Comments

Popular posts from this blog

Programming Languages Used For Artificial Intelligence

The 5 best programming languages for AI development Are you one of the AI aspirants who is confused on which programming language to pick for your next project? Here's a rundown of the best options If so, you've come to the right place, as here we are going to look at the best 4 programming languages for AI development. Artificial Intelligence is a huge field. With so much to cover, it is really hard to refer one single programming language. Clearly, there are many programming languages that can be used, but not every programming language offers you the best value of your time and effort. And there's no authoritative answer as to which programming language you should use for AI project. Python Python is one of the most widely used programming languages in the AI field of Artificial Intelligence thanks to its simplicity. It can seamlessly be used with the data structures and other frequently used AI algorithms. The choice of Python for AI projec

Customized Alert Dialog box and Handling Clicklistener

Hello Geeks ,  It's time to learn new little bit new stuff about the android alert dialog box. It is not so new for the profession engineers but it can help a lot of new beginners who want to improve their knowledge and speed up their productivity. So let's start Just make a method in your utility class and start using.  here is an example //Made: By Umesh Jangid public static void askForInput (Context context , String title , String message , String positiveButtonText , String negativeButtonText , boolean showOnlyOneButton , final AlertDialogCallback<String> callback) { AlertDialog.Builder alert = new AlertDialog.Builder(context) ; alert.setTitle(title) ; alert.setIcon(R.mipmap.ic_launcher) ; alert.setMessage(message) ; alert.setPositiveButton(positiveButtonText != null ? positiveButtonText : "Ok" , new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog , int whichButton) { callbac