Hi all,
I recently got the back button on my android device working in my app so now it will go back to the menu scene when you press the back button. The problem I’m having is when I go from my menu scene to a new scene, then press the back button (to go back to the menu) and try to go to a new scene, I get an error.
I/Corona (30026): Runtime error
I/Corona (30026): ?:0: attempt to call method ‘insert’ (a nil value)
I/Corona (30026): stack traceback:
I/Corona (30026): ?: in function ‘_listener’
I/Corona (30026): ?: in function <?:141>
I/Corona (30026): ?: in function <?:218>
This is the error copied from the cmd window using adb logcat.
Here is my back button code located in main.lua
local function onKeyEvent(event) local phase = event.phase local keyName = event.keyName print( event.phase, event.keyName ) if ( "back" == keyName and phase == "up" ) then if storyboard.currentScene == "scene\_home" then native.requestExit() return true else storyboard.gotoScene( "scene\_home" ) return true end end return false end Runtime:addEventListener( "key", onKeyEvent )
and here is the code being run when my scene exits
function scene:exitScene( event ) local group = self.view if (timeon == true) then timer.cancel(timerid) timeon = false end if (flingTimeOn == true) then timer.cancel(flingTimer) flingTimeOn = false end Runtime:removeEventListener( "touch", changePic ) display.remove( textGroup ) end
I also have a display object that is a button to go back to the menu scene and it works fine. The only time this error happens is with the back button on my android device.
Any thoughts?