Hello. I have had a rejection because some Samsung devices cannot control the volume with the device buttons. I found this code which I have added. I do not have a Samsung device but a few other Android devices and when I set the return to “false” the OS volume graphics comes up with the volume slider and the volume changes. When I set to “true” the OS volume graphics does not appear but the volume changes still. On a previous app I made without any extra code the OS volume graphics appears as usual. So now I am really confused. If the OS volume graphics appear does it mean the code below is not doing anything and that if the OS volume graphics do not appear that is a good thing? I am working blind so is this code correct to make the devices volume control work from the side buttons?
local function onKeyEvent( event )
local phase = event.phase
local keyName = event.keyName
print( event.phase, event.keyName )
if ( “back” == keyName and phase == “up” ) then
native.requestExit()
end
if ( keyName == “volumeUp” and phase == “down” ) then
local masterVolume = audio.getVolume()
print( “volume:”, masterVolume )
if ( masterVolume < 1.0 ) then
masterVolume = masterVolume + 0.1
audio.setVolume( masterVolume )
end
elseif ( keyName == “volumeDown” and phase == “down” ) then
local masterVolume = audio.getVolume()
print( “volume:”, masterVolume )
if ( masterVolume > 0.0 ) then
masterVolume = masterVolume - 0.1
audio.setVolume( masterVolume )
end
end
return false
end
–add the key callback
Runtime:addEventListener( “key”, onKeyEvent )
