1

From the onStartCommand in my service I spawn a thread that begins a very long download process. The problem is that when the user closes the app through the multitasking screen (and they do sometimes), the download thread stops running too.

A while after it stops, the service's onCreate is being called again if I return START_NOT_STICKY in onStartCommand, and is also restarted with a null intent if I return START_STICKY in onStartCommand.

I figured that if I return START_CONTINUATION_MASK in onStartCommand the download thread won't stop when the app is closed through the multitasking screen. But I don't feel like I can trust this flag because I can't find any recommendation to use it.

I don't need to ensure my service will run forever with startForeground, I just need it to keep running after the app is closed at least in most cases (as long as the OS isn't in extreme memory conditions).

What should I do?

Eli Revah
  • 3,626
  • 7
  • 27
  • 33

0 Answers0