简体   繁体   English

Android Jetpack 到底是什么?

[英]What exactly is Android Jetpack?

I've seen the developer keynote of Google I/O 2018, and I've read the jetpack homepage on Android developer website, but I cannot make sense of what it actually is.我看过 Google I/O 2018 的开发者主题演讲,也看过 Android 开发者网站上的 jetpack 主页,但我无法理解它到底是什么。 To me it seems like just a new name for a bunch of APIs we already use.对我来说,这似乎只是我们已经使用的一堆 API 的新名称。 Is there going to be something that the IDE does for us or something that's helpful while coding? IDE 会为我们做些什么,或者在编码时有帮助吗? All the components in Jetpack point to their original Android documentation, and don't actually showcase any difference than before. Jetpack 中的所有组件都指向其原始的 Android 文档,实际上与以前没有任何区别。 Can someone explain in simple terms what Jetpack actually does for me as a developer, apart from clubbing documentation on a web page?除了 web 页面上的俱乐部文档之外,有人可以简单地解释一下 Jetpack 实际上为我作为开发人员做了什么吗?

On its official site, it says:在其官方网站上,它说:

Android Jetpack is a set of libraries, tools and architectural guidance to help make it quick and easy to build great Android apps. Android Jetpack 是一组库、工具和架构指南,可帮助您快速轻松地构建出色的 Android 应用。 It provides common infrastructure code so you can focus on what makes your app unique它提供了通用的基础架构代码,因此您可以专注于使您的应用程序与众不同的地方

Technically, it is the support library, android-ktx and the Android Architecture Components re-branded as a single modular "entity".从技术上讲,它是支持库、android-ktx 和重新命名为单个模块化“实体”的 Android 架构组件。

This is why all non-Android extension libraries like support, etc. are re-packaged to androidx.** .这就是为什么所有非 Android 扩展库如 support 等都被重新打包为androidx.**

Quote from Alan Viverette (from Android Framework Team):引自 Alan Viverette(来自 Android 框架团队):

Jetpack is a larger-scoped effort to improve developer experience, but AndroidX forms the technical foundation. Jetpack 是一项更大范围的改进开发者体验的工作,但 AndroidX 构成了技术基础。 From a technical perspective, it's still the same libraries you'd have seen under Support Library and Architecture Components.从技术角度来看,它仍然是您在支持库和架构组件下看到的相同库。

As best practices change, you may also see libraries in the androidx.* package that are not included in Jetpack.随着最佳实践的变化,您可能还会在 androidx.* 包中看到未包含在 Jetpack 中的库。

See https://developer.android.com/topic/libraries/support-library/refactor for more info.有关更多信息,请参阅https://developer.android.com/topic/libraries/support-library/refactor

Basically it is just set of useful things combined and sorted under 4 categories基本上它只是一组有用的东西组合和分类在 4 个类别下

Foundation基础

Architecture建筑学

Behavior行为

UI用户界面

Some of the core things like AppCompat library, Architecture components, Fragments, Animation and transitions and many more were added now in relative categories and these 5 things were newly added. AppCompat 库、架构组件、片段、动画和过渡等一些核心内容现在已添加到相关类别中,并且这 5 项内容是新添加的。

  1. Android Ktx安卓Ktx

    The purpose of Android KTX is to make Android development with Kotlin more concise, pleasant, and idiomatic by leveraging Kotlin language features such as extension functions/properties, lambdas, named parameters, and parameter default values Android KTX 的目的是通过利用 Kotlin 语言特性,例如扩展函数/属性、lambdas、命名参数和参数默认值,使使用 Kotlin 的 Android 开发更加简洁、愉快和地道

  2. Navigation 导航

    The Navigation Architecture Component simplifies the implementation of navigation in an Android app.This is related to implementing a clear flow in your app.导航架构组件简化了 Android 应用中导航的实现。这与在您的应用中实现清晰的流程有关。 Here in this video you can find a very nice explanation about this topic. 下面这个视频,你可以找到关于此主题的一个非常好的解释。

  3. Paging 分页

    The Paging Library makes it easier for you to load data gradually and gracefully within your app's RecyclerView.分页库使您可以更轻松地在应用程序的 RecyclerView 中逐渐且优雅地加载数据。 Here is the I/O talk from Yigit Boyar, It's very well explained by him. 这是Yigit Boyar 的 I/O 演讲,他解释得很好。

  4. Slices切片

    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. Slices 是 UI 模板,可以在 Google 搜索应用程序中显示来自您的应用程序的丰富、动态和交互式内容,然后在其他地方(如 Google 助理)显示。 Slices can help users perform tasks faster by enabling engagement outside of the full screen app experience. Slices 可以通过在全屏应用体验之外启用参与来帮助用户更快地执行任务。 You can build Slices as enhancements to App Actions.您可以构建切片作为应用操作的增强功能。 Learn more from this talk 从本次演讲中了解更多信息

  5. WorkManager [ I personally recommend you to check this thing out ] WorkManager [我个人建议你检查一下这个东西]

    You can gracefully schedule tasks with WorkManager.The WorkManager API makes it easy to specify deferrable, asynchronous tasks and when they should run.您可以使用 WorkManager 优雅地安排任务。WorkManager API 可以轻松指定可延迟的异步任务以及它们应该何时运行。 These APIs let you create a task and hand it off to WorkManager to run immediately or at an appropriate time.这些 API 允许您创建任务并将其交给 WorkManager 以立即或在适当的时间运行。 This Video explains it in depth.这个视频有深度的解释。

    I have created a playlist Here .我在这里创建了一个播放列表。 It consists all best videos related to Jetpack, Hope this helps.它包含与 Jetpack 相关的所有最佳视频,希望这会有所帮助。

Android Jetpack is a collection of Android software components which helps us in building great Android apps. Android Jetpack 是一组 Android 软件组件,可帮助我们构建出色的 Android 应用程序。

These software components help in:这些软件组件有助于:

  • Following the best practices and writing the boilerplate code.遵循最佳实践并编写样板代码。
  • Making complex things very simple.让复杂的事情变得非常简单。

Earlier there were many challenges which are as follows:之前有很多挑战,如下所示:

  • Managing activity lifecycles.管理活动生命周期。
  • Surviving configuration changes.幸存的配置更改。
  • Preventing memory leaks.防止内存泄漏。

All these major problems have been solved by the Android Jetpack's software components. Android Jetpack 的软件组件解决了所有这些主要问题。

So, the solution for all the problems is Andriod Jetpack.所以,所有问题的解决方案是 Andriod Jetpack。

Another most important thing about the Jetpack is that it gets updated more frequently than the Android platform so that we always get the latest version. Jetpack 的另一个最重要的事情是它比 Android 平台更新得更频繁,以便我们始终获得最新版本。

Jetpack comprises the androidx.* package libraries, unbundled from the platform APIs. Jetpack 包含 androidx.* 包库,从平台 API 中分离出来。 This means that it offers backward compatibility.这意味着它提供了向后兼容性。

Android Jetpack Components Android Jetpack 组件

Android Jetpack components are a collection of libraries that are individually adoptable and built to work together while taking advantage of Kotlin language features that make us more productive. Android Jetpack 组件是一组可单独采用并构建为协同工作的库,同时利用 Kotlin 语言功能提高我们的工作效率。

These software components have been arranged in 4 categories which are as follows:这些软件组件分为以下 4 类:

  • Foundation Components基础组件
  • Architecture Components架构组件
  • Behavior Components行为组件
  • UI Components用户界面组件

Let's see one by one.让我们一一看看。

Foundation Components基础组件

The foundation components provide the following:基础组件提供以下功能:

  • Backward compatibility向后兼容
  • Testing测试
  • Kotlin language support. Kotlin 语言支持。

All the foundation components are as follows:所有基础组件如下:

  • App Compat应用兼容性
  • Android KTX安卓KTX
  • Multidex多索引
  • Test测试

Architecture Components架构组件

The architecture components help us in building:架构组件帮助我们构建:

  • Robust Apps强大的应用程序
  • Testable Apps可测试的应用程序
  • Maintainable Apps可维护的应用程序

All the architecture components are as follows:所有架构组件如下:

  • Data Binding数据绑定
  • Lifecycles生命周期
  • LiveData实时数据
  • Navigation导航
  • Paging分页
  • Room房间
  • ViewModel视图模型
  • WorkManager工作经理

Behavior Components行为组件

The behavior components help in the integration with standard Android services like行为组件有助于与标准 Android 服务集成,例如

  • Notifications通知
  • Permissions权限
  • Sharing分享
  • Assistant助手

All the behavior components are as follows:所有行为组件如下:

  • Download Manager下载管理器
  • Media & playback媒体与播放
  • Notifications通知
  • Permissions权限
  • Preferences喜好
  • Sharing分享
  • Slices切片

UI Components用户界面组件

The UI components provide widgets and helpers to make your app not only easy, but delightful to use. UI 组件提供小部件和帮助程序,使您的应用程序不仅简单,而且使用起来令人愉悦。

All the UI components are as follows:所有 UI 组件如下:

  • Animation and transitions动画和过渡
  • Auto汽车
  • Emoji表情符号
  • Fragment分段
  • Layout布局
  • Palette调色板
  • TV电视
  • Wear穿

Reference article 参考文章

From the blog:来自博客:

Android Jetpack is the next generation of Android components, bringing together the benefits of the Support Library -- backwards compatibility and immediate updates -- to a larger set of components, making it quick and easy to build robust, high quality apps. Android Jetpack 是下一代 Android 组件,将支持库的优势(向后兼容性和即时更新)整合到更多组件中,从而可以快速轻松地构建强大的高质量应用程序。 Android Jetpack manages activities like background tasks, navigation, and lifecycle management, so you can eliminate boilerplate code and focus on what makes your app great. Android Jetpack 管理后台任务、导航和生命周期管理等活动,因此您可以消除样板代码并专注于使您的应用程序出色的方面。 Android Jetpack is designed to work well with Kotlin, saving you even more code with Android KTX. Android Jetpack 旨在与 Kotlin 完美配合,使用 Android KTX 为您节省更多代码。 The new Android Jetpack components released today include WorkManager, Paging, Navigation, and Slices.今天发布的新 Android Jetpack 组件包括 WorkManager、Paging、Navigation 和 Slices。

From official doc:来自官方文档:

Android Jetpack is a set of libraries, developer tools and architectural guidance to help make it quick and easy to build great Android apps. Android Jetpack 是一组库、开发人员工具和架构指南,可帮助您快速轻松地构建出色的 Android 应用程序。 It provides common infrastructure code so you can focus on what makes your app unique.它提供了通用的基础架构代码,因此您可以专注于使您的应用程序与众不同的地方。

在此处输入图片说明

As we all are quoting the official site and it says,正如我们都在引用官方网站所说,

Android Jetpack provides a series of unbundled libraries not tied to any particular version of Android, giving developers a way to support newer features on older versions of the Android operating system. Android Jetpack 提供了一系列未绑定到任何特定 Android 版本的非捆绑库,为开发人员提供了一种方法来支持旧版 Android 操作系统上的新功能。 In addition to backward compatibility, Jetpack promises to help you get more done, with less code, by providing the boilerplate to handle repetitive tasks like managing the application lifecycle.除了向后兼容性之外,Jetpack 还承诺通过提供样板来处理重复性任务(例如管理应用程序生命周期),帮助您用更少的代码完成更多工作。

So now let's break this into bits and pieces, it simply says 2 things所以现在让我们把它分解成点点滴滴,它只是说两件事

  1. So, all the libraries that come under Jetpack are independent of each other.因此,Jetpack 下的所有库都是相互独立的。 You can update any particular library without updating others at the same time.您可以更新任何特定库,而无需同时更新其他库。 You remember those warning,你还记得那些警告,

Those frustrating “All com.android.support libraries must use the exact same version specification” messages should become a thing of the past now.那些令人沮丧的“所有 com.android.support 库必须使用完全相同的版本规范”消息现在应该成为过去。

But that is when you use Androidx libraries and not Support ones.但那是当您使用Androidx库而不是Support库时。

  1. Now all these libraries that come under Jetpack do a lot of boilerplate code at their side, so you don't need to write a lot of code and just worry about the logic.现在 Jetpack 下的所有这些库都在他们身边做了很多样板代码,所以你不需要写很多代码,只需要担心逻辑。 Ex - Remember handling Screen Rotation? Ex - 还记得处理屏幕旋转吗? ( ViewModel takes care of it), Handling infinite scrolling by pagination? ViewModel负责),通过分页处理无限滚动? (now you have Paging library for that), handling back buttons ( Navigation library is there for you), handling dependency injection manually or using Dagger ( Hilt is your friend here), handling different use-cases of Camera and still fixing bugs in production ( CameraX is an easy way going) (just a few of those) (现在你有分页库),处理后退按钮(导航库是为你准备的),手动处理依赖注入或使用 Dagger( Hilt是你的朋友),处理相机的不同用例并仍然修复生产中的错误( CameraX是一个简单的方法)(只是其中的几个)

There are other reasons too to put out JetPack separately, let's discuss those too..单独推出 JetPack 也有其他原因,让我们也讨论一下。

  1. Initially, the name of each package indicated the minimum API level supported by that package, for example, support-v4.最初,每个包的名称表示该包支持的最低 API 级别,例如 support-v4。 However, version 26.0.0 of the Support Library increased the minimum API to 14, so today many of the package names have nothing to do with the minimum supported API level.但是,支持库的 26.0.0 版本将最小 API 增加到 14,因此今天许多包名称与支持的最低 API 级别无关。 When support-v4 and the support-v7 packages both have a minimum API of 14, it's easy to see why people get confused!.当 support-v4 和 support-v7 包的最低 API 都为 14 时,很容易理解为什么人们会感到困惑!。 So now with AndroidX, this confusion disappears.所以现在有了 AndroidX,这种混乱就消失了。

  2. With the current naming convention (support ones), it also isn't clear which packages are bundled with the Android operating system, and which are packaged with your application's APK (Android Package Kit).根据当前的命名约定(支持的命名约定),也不清楚哪些软件包与 Android 操作系统捆绑在一起,哪些与您的应用程序的 APK(Android Package Kit)捆绑在一起。 To clear up this confusion, all the unbundled libraries will be moved to AndroidX's androidx.* namespace, while the android.* package hierarchy will be reserved for packages that ship with the Android operating system.为了消除这种混淆,所有未捆绑的库都将移动到 AndroidX 的 androidx.* 命名空间,而 android.* 包层次结构将保留给 Android 操作系统附带的包。 Simply saying, now on, android.* will be reserved for android operating system related packages, so these packages will anyway start with android.* package name WHILE androidx.* will now be reserved for app development related stuff.简单地说,现在,android.* 将保留用于与 android 操作系统相关的包,因此这些包无论如何都会以 android.* 包名称开头,而 androidx.* 现在将保留用于与应用程序开发相关的内容。

  3. Apart from this, you have:除此之外,你还有:

  • Architectural Component建筑构件
  • Foundational Component基础组件
  • UI component用户界面组件
  • Behaviour Component行为组件

So now, Jetpack is nothing but a name given to the superset of these components, androidx and other tools.所以现在,Jetpack 只不过是这些组件、androidx 和其他工具的超集的一个名称。

Android Jetpack Components Android Jetpack 组件

Android Jetpack components are a collection of libraries that are individually adoptable and built to work together while taking advantage of Kotlin language features that make us more productive. Android Jetpack 组件是一组可单独采用并构建为协同工作的库,同时利用 Kotlin 语言功能提高我们的工作效率。

These software components have been arranged in 4 categories which are as follows:这些软件组件分为以下 4 类:

  • Foundation Components基础组件
  • Architecture Components架构组件
  • Behavior Components行为组件
  • UI Components用户界面组件

Architecture Components架构组件

All the architecture components are as follows:所有架构组件如下:

  • Data Binding: Declaratively bind UI elements to in our layout to data sources of our app.数据绑定:以声明方式将布局中的 UI 元素绑定到应用程序的数据源。
  • Lifecycles: Manages activity and fragment lifecycles of our app.生命周期:管理我们应用程序的活动和片段生命周期。
  • LiveData: Notify views of any database changes. LiveData:通知视图任何数据库更改。
  • Navigation: Handle everything needed for in-app navigation.导航:处理应用内导航所需的一切。
  • Paging: Gradually load information on demand from your data source.分页:按需从数据源逐步加载信息。
  • Room: Fluent SQLite database access.房间:流畅的 SQLite 数据库访问。
  • ViewModel: Manage UI-related data in a lifecycle-conscious way. ViewModel:以生命周期意识的方式管理与 UI 相关的数据。
  • WorkManager: Manage every background jobs in Android with the circumstances we choose. WorkManager:根据我们选择的环境管理 Android 中的每个后台作业。

For more details use below link:- https://blog.mindorks.com/what-is-android-jetpack-and-why-should-we-use-it有关更多详细信息,请使用以下链接:- https://blog.mindorks.com/what-is-android-jetpack-and-why-should-we-use-it

Android Jetpack is a set of libraries that helps you to deal with the challenges you eventually face as a Android Developer — writing boilerplate code, managing activity lifecycles, surviving configuration changes or preventing memory leaks. Android Jetpack 是一组库,可帮助您应对作为 Android 开发人员最终面临的挑战——编写样板代码、管理活动生命周期、在配置更改中幸存或防止内存泄漏。

Jetpack libraries may be used alone or in combination to address different needs in your apps. Jetpack 库可以单独使用或组合使用,以满足您应用程序中的不同需求。

  • WorkManager for your background scheduling needs. WorkManager 满足您的后台调度需求。
  • Room for data storage persistence.数据存储持久性的空间。
  • Navigation to manage your application navigation flow.导航来管理您的应用程序导航流。
  • CameraX for your camera app needs. CameraX 满足您的相机应用需求。

Android Jetpack is a collection of Android software components which helps us in building great Android apps. Android Jetpack 是一组 Android 软件组件,可帮助我们构建出色的 Android 应用程序。 Android Jetpack Components are a collection of libraries ,tools that help in developing robust android applications. Android Jetpack 组件是一组库、工具,可帮助开发强大的 Android 应用程序。 Jetpack comprises the androidx.* package libraries, unbundled from the platform APIs. Jetpack 包含 androidx.* 包库,从平台 API 中分离出来。 This means that it offers backward compatibility.这意味着它提供了向后兼容性。 The software components have been divided into 4 categories:软件组件分为4类:

  • Foundation Components基础组件
  • Architecture Components架构组件
  • Behaviour Components行为组件
  • UI Components用户界面组件

Foundation Components - Foundation Components provide Backward compatibility, Testing, Kotlin support.基础组件 - 基础组件提供向后兼容性、测试、Kotlin 支持。

Foundation Components are:基础组件是:

  • App Compat : The AppCompat library in Jetpack foundation includes all of the components from the v7 library. App Compat :Jetpack 基础中的 AppCompat 库包含 v7 库中的所有组件。 This includes AppCompat, Cardview, GridLayout, MediaRouter, Palette, RecyclerView, Renderscript, Preferences, Leanback, Vector Drawable, Design, Custom tabs, etc. Moreover, this library provides implementation support to the material design user interface which makes AppCompat very useful for the developers.这包括 AppCompat、Cardview、GridLayout、MediaRouter、Palette、RecyclerView、Renderscript、Preferences、Leanback、Vector Drawable、Design、Custom tabs 等。此外,这个库为 Material Design 用户界面提供了实现支持,这使得 AppCompat 对于开发商。
  • Android KTX : KTX stands for Kotlin Extensions ,Android KTX consists of a set of Kotlin extensions that are designed to facilitate developers to remove boilerplate code as well as to write concise code while developing android applications with Kotlin language. Android KTX :KTX 代表 Kotlin Extensions,Android KTX 由一组 Kotlin 扩展组成,旨在方便开发人员在使用 Kotlin 语言开发 Android 应用程序时删除样板代码以及编写简洁的代码。
  • Multidex : Dex is the format of the executable file which runs on the Android virtual machine(known as Dalvik). Multidex :Dex 是运行在 Android 虚拟机(称为 Dalvik)上的可执行文件的格式。 Multidex component also provides support to the collective dex files of an application. Multidex 组件还为应用程序的集体 dex 文件提供支持。
  • Test : includes the Espresso UI testing framework for the runtime UI test and AndroidJUnitRunner for the purpose of unit testing of Android applications. Test :包括用于运行时 UI 测试的 Espresso UI 测试框架和用于 Android 应用程序单元测试的 AndroidJUnitRunner。

Architecture Componets helps in building robust apps.It does not support any particular architecture pattern but suggests clear separation of concerns and controlling of UI from Model by which developers can avoid problems related to activity lifecycle.架构组件有助于构建健壮的应用程序。它不支持任何特定的架构模式,但建议将关注点和 UI 与模型的控制明确分离,开发人员可以通过它避免与活动生命周期相关的问题。

Architecture components are:架构组件是:

  • Room -The Room component acts as an SQLite Object Mapping Library which overcomes challenges from using SQLite like checking the queries at compile-time, writing boiler plate code. Room - Room 组件充当 SQLite 对象映射库,它克服了使用 SQLite 的挑战,例如在编译时检查查询、编写样板代码。 Room converts queries directly into objects, check errors in queries at the compile-time, and is also capable of persisting the Java POJOs. Room 将查询直接转换为对象,在编译时检查查询中的错误,并且还能够持久化 Java POJO。 Sub components are:子组件是:

    1.Entity 1.实体

    2.Data Access Object 2.数据访问对象

    3.Database 3.数据库

  • WorkManager -manage the background tasks in Android which are deferrable(can be run later and is still useful) as well as guaranteed(runs even if the device restarts).WorkManager -管理 Android 中可延迟(可以稍后运行并且仍然有用)以及有保证(即使设备重新启动也可以运行)的后台任务。 It Provides backward compatibility,Scheduling and chaining of tasks is possible ,Users can keep track of/status of the tasks.它提供向后兼容性,可以进行任务的调度和链接,用户可以跟踪任务/状态。

  • LifeCycles -The androidx.lifecycle package components perform actions in response to a change in the lifecycle status of another component, such as activities and fragments. LifeCycles - androidx.lifecycle包组件执行操作以响应另一个组件的生命周期状态的变化,例如活动和片段。 These components help you produce better-organized, and often lighter-weight code, that is easier to maintain.This helps in creating organized application components, ease in testing and maintenance of components, less code requirement to executes tasks.这些组件可帮助您生成组织更好、通常更轻量级、更易于维护的代码。这有助于创建有组织的应用程序组件,简化组件的测试和维护,减少执行任务的代码需求。

  • ViewModel -Manage UI-related data in a lifecycle-conscious way. ViewModel - 以生命周期意识的方式管理 UI 相关数据。 It helps in data management during configuration changes ,Reduce UI bugs and crashes.它有助于在配置更改期间进行数据管理,减少 UI 错误和崩溃。

  • LiveData - Livedata notify the UI of any appropriate change in the data. LiveData - Livedata 通知 UI 数据中的任何适当更改。 If the observer's lifecycle state is destroyed, LiveData is capable to remove it, and thus it avoids memory leaks.如果观察者的生命周期状态被破坏,LiveData 能够删除它,从而避免内存泄漏。 It removes the stopped or destroyed activities which reduce the chance of app crash.它删除停止或销毁的活动,从而减少应用程序崩溃的机会。

  • Navigation Component -Navigation Component get all the benefits of other Architecture components as well like Lifecycle and ViewModel.导航组件 -导航组件获得了其他架构组件以及 Lifecycle 和 ViewModel 的所有好处。 It helps in implementing basic navigation styles like simple button clicks to complex navigation patterns like app bar and navigation drawer.Further, it also supports deep links and helpers which enables the connection of this component with the navigation drawer and bottom navigation.它有助于实现基本的导航样式,如简单的按钮点击到复杂的导航模式,如应用程序栏和导航抽屉。此外,它还支持深层链接和帮助程序,使该组件与导航抽屉和底部导航连接起来。 It ease the transition through animated visualization,s upports deep linking, handle fragment transactions, support common as well as a complex navigation pattern它通过动画可视化简化过渡,支持深度链接,处理片段事务,支持通用和复杂的导航模式

  • Paging - This library provides the facility to load the application data slowly and in a cautious manner.分页- 该库提供了以谨慎的方式缓慢加载应用程序数据的工具。 Easy to integrate with Recycler View in order to display a large data set, compatible with LiveData and RxJava for updating the UI data, loads data gradually with caution.易于与 Recycler View 集成以显示大数据集,兼容 LiveData 和 RxJava 用于更新 UI 数据,谨慎逐步加载数据。

  • Data Binding - Data Binding library is a support library that provides the feature of binding UI components in an activity/fragment to the data sources of the application.数据绑定- 数据绑定库是一个支持库,提供将活动/片段中的 UI 组件绑定到应用程序数据源的功能。 Make code simpler and easy to maintain by removing UI frameworks called in the activity.It also Allows classes and methods to observe changes in data and allows to make objects and filled which works as collection observable.通过删除活动中调用的 UI 框架,使代码更简单和易于维护。它还允许类和方法观察数据的变化,并允许使对象和填充作为可观察的集合工作。

Behaviour Components- Behavior components help in the integration with standard Android services like Notifications,Permissions,Sharing,Assistant.行为组件 - 行为组件有助于与标准 Android 服务(如通知、权限、共享、助手)集成。

Behaviour Components are:行为组件是:

  • Download Manager : The DownloadManager is a system service in Android that helps in downloading bulky files in the background thread.It Schedule and manage large downloads in background with auto retry support.下载管理器下载管理器是 Android 中的一项系统服务,可帮助在后台线程中下载大容量文件。它通过自动重试支持在后台安排和管理大型下载。
  • Media & playback :Jetpack provides a backward-compatible API for the Android multimedia framework.媒体和播放:Jetpack 为 Android 多媒体框架提供了一个向后兼容的 API。 The included Media libraries facilitate developers to integrate audio, video, and image files into an application Backwards compatible APIs for media playback and routing (including Google Cast).包含的媒体库有助于开发人员将音频、视频和图像文件集成到应用程序中,以实现媒体播放和路由(包括 Google Cast)向后兼容的 API。
  • Notifications : Provides a backwards-compatible notification API with Wear and Auto support.通知:提供具有磨损和自动支持的向后兼容的通知 API。
  • Permissions : Compatibility APIs for checking and requesting permissions in app.权限:用于在应用程序中检查和请求权限的兼容性 API。
  • Preferences : Create interactive settings screens for users to configure.首选项:创建交互式设置屏幕供用户配置。
  • Sharing : Provides a share action suitable for an app's action bar.The ShareActionProvider class is used to carry out the task of sharing contents and information.共享:提供适合应用操作栏的共享操作。 ShareActionProvider 类用于执行共享内容和信息的任务。
  • Slices : Create flexible UI elements that can display app data outside the app and can be extended all the way back to Android 4.4. Slices :创建灵活的 UI 元素,可以在应用程序外显示应用程序数据,并且可以一直扩展到 Android 4.4。

UI Components-The UI components provide widgets and helpers that aim to improve the interactions that users have with Android applications. UI 组件 - UI 组件提供小部件和帮助程序,旨在改善用户与 Android 应用程序的交互。

UI Components are:用户界面组件是:

  • Animation and transitions : Jetpack offers APIs to set up different kinds of animations available for Android apps.This framework imparts the ability to move widgets as well as switching between screens with animation and transition in an application.动画和转换:Jetpack 提供 API 来设置可用于 Android 应用程序的不同类型的动画。该框架赋予移动小部件以及在应用程序中具有动画和转换的屏幕之间切换的能力。

  • Auto : Components to develop Android Auto apps.The following category of applications can be built, test, and distributed on Android Auto: Navigation apps,Messaging apps,Media apps. Auto :用于开发 Android Auto 应用程序的组件。可以在 Android Auto 上构建、测试和分发以下类别的应用程序:导航应用程序、消息应用程序、媒体应用程序。

  • Emoji : Enable updated emoji font on older platforms.表情符号:在旧平台上启用更新的表情符号字体。 Google has released new library called EmojiCompat in order to handle emoji characters and to use downloadable font support.The backward compatibility of this library is up to Android 4.4(API level 19). Google 发布了名为 EmojiCompat 的新库,以处理表情符号字符并使用可下载的字体支持。该库的向后兼容性高达 Android 4.4(API 级别 19)。

  • Fragment : Represents a behaviour or portion of the user interface, used for dynamic and flexible UI designs (and to reduce boilerplate layouts and code). Fragment :代表用户界面的一个行为或一部分,用于动态和灵活的 UI 设计(并减少样板布局和代码)。

  • Layout : Are used for creating and designing the structure of the user interface.布局:用于创建和设计用户界面的结构。

  • Palette : Used for designing layout themes and to apply custom colors to the elements of the app. Palette :用于设计布局主题并将自定义颜色应用于应用程序的元素。

  • TV : Components to develop Android TV apps. TV :开发 Android TV 应用程序的组件。

  • Wear : Components created to help develop apps for Wear. Wear :创建用于帮助开发 Wear 应用程序的组件。

Android Jetpack is a set of libraries which makes life of android developers easy. Android Jetpack 是一组库,可让 Android 开发人员的生活变得轻松。 Android development can be done without jetpack also, but it gives your applications more modular, application life-cycle aware and more testable. Android 开发也可以在没有 jetpack 的情况下完成,但它使您的应用程序更加模块化、应用程序生命周期感知和更可测试。

For instance, Work manager is a Jetpack component which is used for scheduling tasks for may get triggered when suitable conditions meet (like device is plugged in).例如,工作管理器是一个 Jetpack 组件,用于调度任务,因为在满足合适的条件时可能会触发(例如插入设备)。 Applications can be developed without using Workmanager also (Using Jobschedular), but developer will not have more options.也可以在不使用 Workmanager 的情况下开发应用程序(使用 Jobschedular),但开发人员将没有更多选择。

Android Jetpack is a set of libraries which makes life of android developers easy. Android Jetpack 是一组库,它使 android 开发人员的工作变得轻松。 Android development can be done without jetpack also, but it gives your applications more modular, application life-cycle aware and more testable. Android 开发也可以在没有 jetpack 的情况下完成,但它使您的应用程序更加模块化、应用程序生命周期感知和更可测试。

For instance, Work manager is a Jetpack component which is used for scheduling tasks for may get triggered when suitable conditions meet (like device is plugged in).例如,Work manager 是一个 Jetpack 组件,用于安排任务,可能会在满足合适的条件(如插入设备)时触发。 Applications can be developed without using Workmanager also (Using Jobschedular), but developer will not have more options.也可以在不使用 Workmanager 的情况下开发应用程序(使用 Jobschedular),但开发人员不会有更多选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM