I’m having trouble making the native button “back” on the android work correctly.
I tried everything and searched all over the subject on the internet and could not find a solution.
The app I’m creating has a button that rewinds scenes created with Composer.
But I would like to make this possible also through the Android back button.
Everything I have tried does not work correctly and the event propagates through all scenes because I am not able to cancel/remove the “Runtime: addEventListener” in each scene.
Here is part of my code to try to implement that function:
local function onKeyEvent( event ) local platformName = system.getInfo( "platformName" ) if ( platformName == "Android" ) then if ( event.keyName == "back" ) then composer.gotoScene( "scene1" ) composer.removeScene( "scene2" ) Runtime:removeEventListener( "key", onKeyEvent ) return true end end return false end -- -- Runtime:addEventListener( "key", onKeyEvent )
I appreciate if you can give me a solution that works and can be implemented within the pages I created with Composer.
Thank you,
Daniel