通过数据类发送类对象 [英] Sending class object through Data class
问题描述
Android最近引入了 WorkManager 用于计划任务. WorkManager 的强大功能之一就是通过合并, beginWith 运算符. Data 类用于在这些任务之间发送数据.但是经过数据和数据类在不同任务之间,甚至没有通过可包裹. 如何在不同任务之间发送类对象?
Android has recently introduced WorkManager for scheduling tasks. One of the powerful feature of this WorkManager is chaining multiple tasks through combine, then and beginWith operators. Data class is being used to send data between these tasks. But After going through the Data and Data.Builder class, I haven't found the way to send Class object through Data class between different tasks, not even through Serializable or Parcelable. How can I send class object between different tasks?
推荐答案
Data
是一个轻量级的容器,它是一个简单的键值映射,并且只能保存基本&的值.字符串及其字符串版本.这实际上是为了进行轻量级的,中间的数据传输.它不应该用于且不能容纳Serializable或Parcelable对象.
The Data
is a lightweight container which is a simple key-value map and can only hold values of primitive & Strings along with their String version. It is really meant for light, intermediate transfer of data. It shouldn't be use for and is not capable of holding Serializable or Parcelable objects.
请注意,序列化时数据大小限制为10KB.
Do note, the size of data is limited to 10KB when serialized.
这篇关于通过数据类发送类对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!