Android: upload files totally in background

This library - https://github.com/gotev/android-upload-service 2.3K stars Apr 2020

enter image description here

" -Easily upload files (Multipart/Binary/FTP out of the box) in the background with progress indication notification

-upload files to a server with FTP, HTTP multipart/form-data or binary requests

-handle multiple concurrent uploads in the background, even if the device is idle (Doze mode)

-automatically retry failed uploads, with a configurable exponential backoff possibility to automatically delete uploaded files when the upload is successful

Apps and libraries powered by this library-

-JIRA Cloud

-Quora

...

"


You should use Service for this purpose. It will be running on background, and in it you can do all your upload/download work. You can look at this tutorial, and also read more about it from official documentation here and here.

You can just move all your logic from Activity/Fragment to Service, and it will be do it in background, even if your app is closed.