I have an Android app that connects to surrounding devices currently running the same app, even if in background.
To do this, I use WiF-Direct to advertise the fact that I am currently running said application.
Therefore I need to stop advertising this as soon as the app is killed.
onDestroy()
cannot be used since it is not guaranteed to be called.onStop()
andonPause()
cannot be used since the app is still running.
How can I achieve this?
Currently the service is still being advertised even when the application is closed/killed.