My app plays a sound while the device is locked (keyguard). I use Android MediaPlayer. The user can controll the sound's volume by pressing the hardware volume keys. I do not want the user to be able to change the volume while the device is locked. How can I disable the volume keys while device is locked?
I tried How to override the behavior of the volume buttons in an Android application?
dispatchKeyEvent and Onkeydown didn't work for me. I also tried setVolumeControlStream() but it didn't work. The user always can change the volume by pressing the volume key.