1

I asked a question: Disable service restart on button click about service. The answer I recieved is I should try to use WorkManager. I did, but I noticed when the app is killed the WorkManagers stops download. So the work manager is replacment for Foreground service or it is not sutible for large file download in backround?

My start of work manager:

        val workManager = WorkManager.getInstance()
        val constraints = androidx.work.Constraints.Builder().setRequiredNetworkType(NetworkType.NOT_REQUIRED).build()
        val task = OneTimeWorkRequest.Builder(DownLoadFileWorkManager::class.java).setConstraints(constraints).build()
        workManager.enqueue(task)
Dim
  • 4,527
  • 15
  • 80
  • 139
  • What is the brand of the device you are testing? Chinese manufacturers usually kill background processes if your app isn't a well-known app like Facebook or Whatsapp etc. Consider testing with Pixel Emulator. – okan Dec 07 '20 at 09:04
  • I am using Samsung A51 – Dim Dec 07 '20 at 09:06
  • this should give you more insights on now OEM's handle process. https://stackoverflow.com/questions/50682061/android-is-workmanager-running-when-app-is-closed. Also, try using DownloadManager ( https://developer.android.com/reference/android/app/DownloadManager ) – Sahitya Pasnoor Dec 07 '20 at 09:52

0 Answers0