Reputation: 3
I have a one time (WorkManager) worker with some logic that allows it to retry (Result.retry()) when some conditions are not met. If this worker has been running and has a scheduled retry, what happens when I update the code of that worker and the user then updates the app? Would it:
I'm inclined to think it would be #3 but not really sure.
Upvotes: 0
Views: 446
Reputation: 6496
Tldr: WorkManager will run the new code (option 2).
WorkManager keep tracks of the scheduled work in a room database saving the classname of the Worker, this independently of the version of the application installed on the device and the version of the app that enqueued the request.
You may implement some migration rules to run the first time a new version is run if you need to change the default behavior.
Note A migration is required if you change your Worker's classname or remove it a Worker altogether. In this case you need to cancel the enqueued requests for those Workers or it will fail with a ClassNotFound Exception.
Upvotes: 1