Android still has no control with hardware buttons?

So i have searched in the forums and seen in the past that corona cannot communicate with the hardware buttons on android phones, i just wanted to double check and see if that is still the case? If that is the case, im wondering if there is any possibility of disabling the "back" button. Because with the way things currently are when people push the back button or the home button, it just exits the app completely. Any info would be great thanks

The newest release of Corona "does" support the Android buttons via "key" events. Please see sample app "Hardware\KeyEvents" included in the Corona SDK.

Here is the API documentation...
http://developer.anscamobile.com/reference/index/events/key

glad to hear it, thank you for the quick response

So here is my code,

1
2
3
4
5
6
7
8
9
10
11
local function onKeyEvent( event )
        local returnValue = true
        
        local phase = event.phase
        if phase == "back" then
                audio.play(clickSound)
        end
        return returnValue
end
 
Runtime:addEventListener( "key", onKeyEvent )

nevermind i figured out what i was doing wrong, i was telling it to give me the phase rather than what button was pressed, this is how you can get both the phase and the keypress

1
2
3
4
5
6
7
8
9
10
11
local function onKeyEvent( event )
        local returnValue = true
        
        local phase = event.phase
        local whatKey = event.keyName
        if whatKey == "back" and phase == "down" then
                audio.play(clickSound)
        return returnValue
end
 
Runtime:addEventListener( "key", onKeyEvent )

Great! I'm glad it's working for you!

views:1651 update:2011/10/8 8:54:25
corona forums © 2003-2011