5
I found a palliative solution, which keeps monitoring the change in the volume of the system itself. When the volume decreases, for example, from 10 to 9, the program resets the volume back to 10 (pretending there was no change in volume) and performs the desired action (idem for when the volume increases).
This solution works on several devices, but I find this solution kind "gambiarra".
Someone knows a mode, which does not involve root or custom ROMS, to monitor and handle the physical keystrokes of volume with the screen locked, from a service?
Thanks a lot!
Updating
Solution types like the one that Gravitybox uses only work if the device is root... Still, I would like something as close as possible:
Yeah, I’m gonna re-edit the question. It would have to be from inside a service.
– carlosrafaelgn
Thanks! But the solution with Alarmmanager could not act as quickly as the solution I already found. It has to be something instantaneous, or as close to it as possible.
– carlosrafaelgn
But you can set Alarmmanager for every 1 second.
– lucasb.aquino
This type of solution that is always running and checking (known as pooling) ends up spending more CPU and battery than necessary, and the response time is not always satisfactory. In this case, with the solution I found of monitoring the volume via callback, there is pooling, and the response time is almost instantaneous... But still, the user feels for a brief moment (few milliseconds) that there has been a change in volume :( I wanted to avoid this, and try to be notified about the physical pressing of the key, if possible.
– carlosrafaelgn
I believe that the solution within the criteria you determined does not exist, at least not to access without Root.
– lucasb.aquino
I’m also coming to that conclusion. I’ve already reviewed the internet, unsuccessfully. But there are always hopes ;)
– carlosrafaelgn