1

I want to track the location of a person in a foreground service. For legitimate and legal reasons, I want to track the user's location continuously, even after the application is swiped from recents screen

Please note that the solutions provided here and here won't work as onDestroy() onTaskRemoved() won't be called when user swipes the application from recents.

Also, using Broadcast Receivers won't be of any help, as they only work when the task is not cleared.

I've also tried using a ViewModel and calling onCleared(). Even that doesn't seem to work.

Is there any way of doing this.

I need to keep the service running in the foreground as that is the primary need for my app.

Sai Prashanth
  • 144
  • 2
  • 11

1 Answers1

0

you can use WorkManager for this here

  • I would like to start this service immediately, as soon as it closes. using a `workmanager` won't start the service immediately right?. Is there any workaround to start the service immediately? – Sai Prashanth Jun 18 '20 at 10:02
  • Also, I've just discovered that we cannot start a foreground service from the background – Sai Prashanth Jul 09 '20 at 09:31