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?
Asked
Active
Viewed 1,752 times
2
-
potentially an XY problem. why would you want to send a class? – Tim May 16 '18 at 09:26
2 Answers
2
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.
Do note, the size of data is limited to 10KB when serialized.

Sagar
- 23,903
- 4
- 62
- 62
-
where have you found the limitation of 10KB? Can you provide a link to the source / documentation? – hardysim Mar 13 '19 at 08:03
-
1@hardysim you can refer to https://developer.android.com/reference/androidx/work/Data . Read second paragraph. – Sagar Mar 13 '19 at 12:03