I have developed an android watch app. It has a play button which when you click starts the sensor manager to analyse the sensor data. Using the data, I recognize the gestures performed by the user. So when I press the play button, sensor data analysis starts and the user can see a stop button to stop the sensor whenever he wants. So once the sensor is started, if I swipe and go back to the home screen and the again open the app, I can see the play button instead of stop button. I want to see the stop button when the user returns. Ideally I want to run a foreground service to detect the sensor readings.
So I want to start a foreground service when the user hits the play button and when the user open the notification, he must see the stop button to stop the sensor data as well as the service. How can I do this? Please advise.