BT

Android Jetpack Brings WorkManager, Navigation and More

| by Diogo Carleto Follow 46 Followers on May 23, 2018. Estimated reading time: 2 minutes |

Android Jetpack brings new components, tools and architectural guidance to develop Android apps. The new components are WorkManager, Navigation, Paging, Slices and Android KTX.

The Android Jetpack components bring together the existing Support Library and Architecture Components and arrange them into four categories:

The components of Android Jetpack are provided as "unbundled" libraries that are not part of of the underlying Android platform. This means that developers can adopt each component at their own speed. Furthermore, the unbundled Android Jetpack libraries have all been moved into the new androidx.* namespace (as described in detail in this post).

In addition, an app can run on various versions of the Android platform because Android Jetpack components are built to provide their functionality independently of the underlying Android version, thus providing backwards compatibility.

WorkManager is a new library that provides a solution for constraint-based background jobs replacing the need to use things like jobs or SyncAdapters. WorkManager provides a simplified, modern API, that intends to make it easy to specify asynchronous tasks, to work on devices with or without Google Play Services.

Navigation simplify the implementation of navigation, aiming to make single-activity apps the preferred architecture. With out-of-the-box support for fragments, it is possible to get all  benefits of the Architecture Components such as Lifecycle and ViewModel while Navigation handle the complexity of FragmentTransactions for you. You can visually see and manage navigation properties using Navigation Editor in Android Studio 3.2.

Paging 1.0.0 makes it easy to load and present large data sets with fast, infinite scrolling in your RecyclerView. It can load paged data from local storage, network, or both, and lets you define how your content gets loaded. It works out of the box with Room, LiveData, and RxJava.

Slices are UI templates that can display rich, dynamic, and interactive content from your app from within the Google Search app and in other places like Google Assistant. Slices can help users perform tasks by enabling engagement outside of the fullscreen app experience.

Android KTX is a set of Kotlin extensions. It optimizes Jetpack and Android platform APIs for Kotlin use. Android KTX aims to make Android development with Kotlin more concise, pleasant, and idiomatic. It lets you transform Kotlin code like this:


view.viewTreeObserver.addOnPreDrawListener(
 object : ViewTreeObserver.OnPreDrawListener {
   override fun onPreDraw(): Boolean {
     viewTreeObserver.removeOnPreDrawListener(this)
     actionToBeTriggered()
     return true
   }
});

into more concise Kotlin code like the following:


view.doOnPreDraw { actionToBeTriggered() }

You can get started with Android Jetpack at developer.android.com/jetpack. There is also a YouTube playlist devoted to Android Jetpack, where it is possible to find information about Android Jetpack, components, tools and best practices.

Getting Started with Android Jetpack tells you how to bring Android Jetpack into an existing project or start a new one. Android Studio 3.2 supports Android Jetpack. You can provide feedback for Jetpack.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT