Search This Blog

Saturday, May 19, 2018

Android - What is Android Jetpack?

Google has introduced Android Jetpack for enhancing mobile development. Jetpack is a set of components, tools, and guidance to make great Android apps. It's components bring together the existing Support Library and Architecture Components and arranges them into four categories as you can see below.

Jetpack combines the existing Android support libraries and components and wraps them into a new set of components, like:

1. Background tasks.
2. Navigation.
3. Paging.
4. Life-cycle management.
5. UI features like emoji and layout control for various platforms( Android Wear, Auto, and TV).

Android Jetpack components are provided as unbundled libraries that are not part of the Android platform. It means, you can use each component at your own speed.  You can run the app on various versions of the platform because Android Jetpack components are built to provide their functionality independent of any specific version. This makes it far easier for you to build robust, high-quality apps with less code.

Android Jetpack has included five new components:

1. WorkManager alpha release.
2. Navigation alpha release.
3. Paging stable release.
4. Slices alpha release.
5. Android KTX (Kotlin Extensions) alpha release.

WorkManager:- It is a powerful new library that provides a solution for constraint-based background tasks that need guaranteed execution. It is replacing the need to use things like jobs or SyncAdapters. WorkManager provides a simplified, modern API, the ability to work on devices with or without Google Play Services. These APIs let you create a task and hand it off to WorkManager to run immediately or at an appropriate time.

Example:- Let' assume, we need to download new resources from the network from time to time. You can set up a task and choose the appropriate constraint for it to run, like only while the device is charging and online. WorkManager will run it when the conditions are met. The task is guaranteed to run, even if your app is force-quit or the device is rebooted.

Navigation:- Activity is the system provided entry points into the application and it can share data between each other and transitions has made them a less than ideal architecture for constructing your in-app navigation.

In Android Studio 3.2, we have Navigation component that can structure your in-app UI, with a focus on making a single-Activity app the preferred architecture. You can get all of the Architecture components benefits such as Lifecycle and ViewModel while allowing Navigation to handle the complexity of FragmentTransactions for you.

It will allow you to declare transitions and automatically builds the correct Up and Back behavior, includes full support for deep links, and provides helpers for connecting Navigation into the appropriate UI widgets, like the navigation drawer and bottom navigation.

Paging:- Pagination (Endless Scrolling or Infinite Scrolling) is a feature common in content-heavy apps. It breaks down a list of content into equal smaller pieces, loaded one at a time. 

Now, we have paging component version 1.0.0 that makes pagination easy to load and present large data sets with fast, infinite scrolling in your RecyclerView. It can load paged data from local storage, the network, or both, and lets you define how your content gets loaded.

Slices:- It is the great way to promote app on Google Assistant. With the help of Slices component, you can share small part(UI) with the google search. Slices are UI templates that can display rich, dynamic, and interactive content from your app from within the Google Search app and later in other places like the Google Assistant.

Android KTX:-  Android Jetpack takes advantage of Kotlin language features that make you more productive. The purpose of Android KTX is to make Android development with Kotlin more concise, pleasant, and idiomatic by leveraging Kotlin language.

Android KTX lets you transform Kotlin code like this:
object : ViewTreeObserver.OnPreDrawListener { override fun onPreDraw(): Boolean { viewTreeObserver.removeOnPreDrawListener(this) actionToBeTriggered() return true } });
Android KTX transform above code into more concise Kotlin code like the following.
view.doOnPreDraw { actionToBeTriggered() }

So, here all that i found about Android Jetpack. If anything missed you can share below.



Post a Comment


Facebook Gruop


  • Cover art Blend

    Blend app is very advanced app there are lots of features like shayari, status, chat, feed....