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)