通过数据类发送类对象 [英] Sending class object through Data class

查看:76
本文介绍了通过数据类发送类对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android最近引入了 WorkManager 用于计划任务. WorkManager 的强大功能之一就是通过合并 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆