In case the work is preempted and later restarted for any reason, a new instance of
ListenableWorker is created. This means that startWork is called exactly once per
ListenableWorker instance. A new ListenableWorker is created if a unit of work needs to be
rerun.

A ListenableWorker is given a maximum of ten minutes to finish its execution and return a
ListenableWorker.Result. After this time has expired, the worker will be signalled to stop and its
ListenableFuture will be cancelled.

isStopped

public final boolean isStopped ()

Returns true if this Worker has been told to stop. This could be because of an
explicit cancellation signal by the user, or because the system has decided to preempt the
task. In these cases, the results of the work will be ignored by WorkManager and it is safe
to stop the computation. WorkManager will retry the work at a later time if necessary.

Returns

boolean

true if the work operation has been interrupted

onStopped

public void onStopped ()

This method is invoked when this Worker has been told to stop. This could happen due
to an explicit cancellation signal by the user, or because the system has decided to preempt
the task. In these cases, the results of the work will be ignored by WorkManager. All
processing in this method should be lightweight - there are no contractual guarantees about
which thread will invoke this call, so this should not be a long-running or blocking
operation.

startWork

Override this method to start your actual background processing. This method is called on
the main thread.

A ListenableWorker is given a maximum of ten minutes to finish its execution and return a
ListenableWorker.Result. After this time has expired, the worker will be signalled to stop and its
ListenableFuture will be cancelled.