Android Question Consume volume button and prevent volume change

Beja

Expert
Licensed User
Longtime User
Hi,
I am working on alarm system, and don't want the user to disable or lower the volume. A lot of useful information is on the forum, but didn't find any of them specific to what I need. To set the volume to maximum and prevent the user from changing it.
Code example, please!

thanks in advance.
 

derez

Expert
Licensed User
Longtime User
You can use this:

To set the volume to max -

to inhibit volume down -

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event
If KeyCode = KeyCodes.KEYCODE_VOLUME_DOWN Then ....
 
Last edited:
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Is it just to avoid a false manipulation? Because, in any other case, the user will just have to switch to another application or press Home before changing the volume.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…