diff --git a/src/android/FileTransferBackground.java b/src/android/FileTransferBackground.java index 27841a0e..ed650b90 100644 --- a/src/android/FileTransferBackground.java +++ b/src/android/FileTransferBackground.java @@ -244,6 +244,11 @@ private void initManager(String options, final CallbackContext callbackContext) this.uploadCallback = callbackContext; this.ready = true; + + // If we have pending jobs, start the workers. + if (AckDatabase.getInstance(cordova.getContext()).pendingUploadDao().getPendingUploadsCount() > 0) { + startWorkers(); + } } private void addUpload(JSONObject jsonPayload) { @@ -329,13 +334,16 @@ private void addUpload(JSONObject jsonPayload) { ) ); - if (!workerIsStarted) { - startWorkers(); - workerIsStarted = true; - } + startWorkers(); } private void startWorkers() { + if (workerIsStarted) { + return; + } + + workerIsStarted = true; + logMessage("startUpload: Starting worker via work manager"); for (int i = 0; i < ccUpload; i++) {