I'm building an app that communicates with an industrial PLC over WiFi.
The aim is to have a button that constantly sending alive signal to the system. Once the button was pressed, or the communication was lost, the machine will stop.
All the communication layer is fully working, running on a foreground service. The big obstacle is to apply the button.
To keep it simple, I wanted to connect it to the headphone jack and use mediaservice to catch the button event. It works, but as I mentioned the button is constantly pressed, so the assistant keeps popping up.
I'm trying to think on a way to override the system events even when the activity is closed.
I saw several apps who manage to do this using accessibility services.
Can you think of a way?