-1

How to make an unstoppable service. That'll be working in background. (this service will be used to upload large file to server) With these case.

If user closes app while service is running, it should continue working

I don't know what should be used in this case. All I need is to make service work in background... Can anyone help me with that? Note that minimum sdk is 17

Community
  • 1
  • 1
George Samir
  • 47
  • 1
  • 6
  • please use the following https://stackoverflow.com/questions/4360074/creating-a-service-in-android – hussain Aug 03 '19 at 23:41
  • I have tried service and intent service but when i closed app, i can't understand what's happened, all i get is retrofit stop it's task.. Don't knoe why – George Samir Aug 03 '19 at 23:46

1 Answers1

0

You can use WorkManager's OneTimeWorkRequest for uploading large files to the server.

But still, if your system doesn't have enough resources this work will be canceled by the system. So if you detect the work has failed then you can schedule a periodic work request to upload the file later when system's resources are free.

WorkManager

OneTimeWork Request

PeriodicWork Request

Kashish Sharma
  • 749
  • 8
  • 18