Search code examples
androidservicebackground

How to keep the file upload process running in the background of the app in Android Studio?


How to keep the file upload process running in the background of the app? Android Studio, Java. I was able to successfully upload the file but after exiting the app the upload process stopped. I want the upload process to not stop even if the user exits the app.


Solution

  • You can use WorkManager to manage background tasks of your app. See documentation: https://developer.android.com/develop/background-work/background-tasks/persistent/getting-started#define_the_work

    Or you can use Foreground service (with notification) to keep your task alive while uploading: https://developer.android.com/develop/background-work/services/foreground-services