There is no any official doc (as I have read the docs at least) that explain the usage and the mechanism behind these two modes . How do they work ? And what problem do they solve ?
I will appreciate that if anyone can simplified it for me , because I have tested both and have not seen any interesting thing . If you ask me , I would say that OneTimeWorkRequest.setBackoffCriteria()
does not affect to the work .
Here are my codes ,
@Override
public void doSomethingUseful(String order) {
Constraints constraint = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build();
Data data = new Data.Builder()
.putString("order", order)
.build();
OneTimeWorkRequest oneTimeWorkRequest = new OneTimeWorkRequest.Builder(OrderSenderWorker.class)
.setConstraints(constraint)
.setInputData(data)
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 15, TimeUnit.SECONDS)
.build();
WorkManager.getInstance().beginUniqueWork("refresh-order", ExistingWorkPolicy.REPLACE, oneTimeWorkRequest).enqueue();
}
And in Worker
class whenever I get something wrong , I do return WorkerResult.RETRY
in doWork()
method.
Thanks in advance .