How can we pass Serializable object in work manager by setData method of work manager? Is there any way to process with Work manager by passing object?
WorkManager is a library used to enqueue work that is guaranteed to execute after its constraints are met. WorkManager allows observation of work status and the ability to create complex chains of work.
Map<String, Object> map = new HashMap<>();
AddressBookData addressBookData = new AddressBookData();
addressBookData.setThreadId(001);
map.put("AddressBookData", addressBookData);
Data data = new Data.Builder()
.putAll(map)
.build();
OneTimeWorkRequest compressionWork =
new OneTimeWorkRequest.Builder(DataSyncWorker.class)
.setInputData(data)
.build();
It crash app and showing error like AddressBookData is not valid class.
Note: I want to pass POJO class in work manager and get InputData from work manager in doWork Method.