Take you through the Android Jetpack

1.Jetpack main features are the following three points:

1. accelerate the development
component may be used alone, can work together, when a language characteristic kotlin efficiency can be improved.

2. Elimination of boilerplate code
Android Jetpack can manage cumbersome Activity (such as a background task, navigation and life-cycle management).

3. Build high-quality powerful application
Android Jetpack component is built around modern design practice, backward compatibility, you can reduce crashes and memory leaks.

 

2.Jetpack of classification.

e6R24K.png

DataBinding: declaratively observed to bind data interface elements, usually with the use ViewModel.
Lifecycle: Activity and Fragment for managing the life cycle, can help developers generate the code easier to maintain lightweight.
LiveData: notify the view when the underlying database changes. It is a data holder observable with conventional observable different, LiveData is the life cycle of perception.
Navigation: Navigation within the application process.
Paging: a developer can help to load and display pieces of data, some data can be loaded on demand network bandwidth and reduce the use of system resources.
Room: friendly and smooth access SQLite databases. It provides an abstraction layer on the basis of SQLite, allowing more powerful database access.
ViewModel: interface to manage the life cycle of related data, DataBinding and usually used in conjunction, provide strong support for the developers to implement MVVM architecture.
WorkManager: Android management background job, even if the application exits or restarting the device may also be delayed running asynchronous tasks.

3. introducing in the application related components Jetpack

Add items build.gradle the Google () library, as follows.

allprojects {
      repositories {
          google()
          jcenter()
      }
  }

If you want to introduce Room, could write in block build.gradle in:

implementation   "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor   "android.arch.persistence.room:compiler:1.1.1 "
androidTestImplementation  "android.arch.persistence.room:testing:1.1.1"

 

Guess you like

Origin www.cnblogs.com/ganchuanpu/p/11617476.html