Sending class object through Data class

对着背影说爱祢 提交于 2019-12-13 00:54:44

问题


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?


回答1:


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.




回答2:


I asked the same question here

@Sagar does point out the correct answer to your question, just posting my answer here for people looking for potential work arounds.



来源:https://stackoverflow.com/questions/50366767/sending-class-object-through-data-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!