Skip to content

Commit

Permalink
Fix crash in Android 8 when the ownCloud app is in background and tri…
Browse files Browse the repository at this point in the history
…es to retry an upload
  • Loading branch information
davigonz committed Nov 13, 2017
1 parent 7b8316f commit d008ca7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/com/owncloud/android/files/services/TransferRequester.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,19 @@ public void retryFailedUploads(Context context, Account account, UploadResult up
*/
private void retry(Context context, Account account, OCUpload upload) {
if (upload != null) {
Intent i = new Intent(context, FileUploader.class);
i.putExtra(FileUploader.KEY_RETRY, true);
i.putExtra(FileUploader.KEY_ACCOUNT, account);
i.putExtra(FileUploader.KEY_RETRY_UPLOAD, upload);
context.startService(i);
Intent intent = new Intent(context, FileUploader.class);
intent.putExtra(FileUploader.KEY_RETRY, true);
intent.putExtra(FileUploader.KEY_ACCOUNT, account);
intent.putExtra(FileUploader.KEY_RETRY_UPLOAD, upload);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (upload.getCreadtedBy() ==
CREATED_AS_PICTURE || upload.getCreadtedBy() == CREATED_AS_VIDEO)) {
// Since in Android O the apps in background are not allowed to start background
// services and camera uploads feature may try to do it, this is the way to proceed
context.startForegroundService(intent);
} else {
context.startService(intent);
}
}
}

Expand Down

0 comments on commit d008ca7

Please sign in to comment.