Should we cancel sync to avoid retries when the device is largely offline? #2021
-
Currently we schedule periodic sync when the application is started either in online or offline mode. When the device is offline does it make sense to still schedule the sync? If we don't we at some point need to run sync when the device gets back online so we will need some sort of listener to know when the device is back online. The sync failure exception is currently handled so there would be no app crashes even if the device attempt to sync data while offline. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Workmanager provides a For example:
We could also use For more see the documentation here: Android Background Work |
Beta Was this translation helpful? Give feedback.
-
Not sure we have this configured/factored in but the underlying JobScheduler API in Android limits the Workers to prevent them from running for more than 10 minutes. After that interval the OS stops the Worker. There are recommended workarounds for supporting such long running tasks documented here. https://developer.android.com/guide/background/persistent/how-to/long-running |
Beta Was this translation helpful? Give feedback.
Workmanager provides a
Constraints
class object which we could use to specify that certain jobs should only run if there's an internet connectionFor example:
We could also use
NetworkType.NOT_REQUIRED
to signal that that specific job Does Not require connectivityFor more see the documentation here: Android Background Work