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.