I know that services cannot implement Back key press and I understand the rationale. But there is an app called SideBar (on Play Store) that reacts to back key presses. It is a service that adds a view as system overlay and removes the view when the back key is pressed. Can anybody explain how this is done?
Here is another app that does it well. I have scoured the web, but have not found a solution to this problem. Any ideas?
here is nice example to addview in Service and also you can use listeners if you want in services.
i was also looking for the listeners implementation in service and finally found it.
remember to add permission
and add your service class
in AndroidManifest.xml.
It is probably done using system alert windows - so the service creates and manages a window that is added to the window manager, which has a custom callback set on it.