Hi everybody,
Im dealing with a really weird bug and can’t find anything by debuggin or googling…
Basicly, i’ve made a function that listens for the back button and goes back one screen:
[lua]-- Key listener
function onKeyEvent( event )
local phase = event.phase
local keyName = event.keyName
print(“1”)
if phase == “up” and keyName == “back” then
print(“2”)
if #breadcrumbs > 1 and androidBackEnabled == true and not modal.lastModal then
print(“3”)
goto(“back”);
elseif currentType == menu_splash then
print(“4”)
if tappedBackTwice then
print(“6”)
os.exit();
else
print(“5”)
toast.new(language.get(“general”, “toast_close_app”), 3000)
tappedBackTwice = true;
timer.performWithDelay(3000, function() tappedBackTwice = false end);
end
end
end
end
local isSimulator = system.getInfo(“environment”) == “simulator”;
function onTilt(event)
if event.isShake then
onKeyEvent({
phase = “up”,
keyName = “back”,
})
end
end
– Add the key callback
Runtime:addEventListener( “key”, onKeyEvent )
if ( isSimulator ) then Runtime:addEventListener( “accelerometer”, onTilt ) end[/lua]
As you can see i’ve added print statements all the way up to where my view manager will receive the ‘back’ command.
The situation is; on the simulator this code runs just fine and even when i call the function goto(‘back’) from a regular on screen button nothing goes wrong.
However, when i press the physical back button on an android device i can see the view starting it’s transition effect, and after about half a second it crashes just like that…
The only output i am getting is:
[text]
I/Corona (24499): 1
I/Corona (24499): 1
I/Corona (24499): 2
I/Corona (24499): 3
I/Corona (24499): Lua Runtime Error: lua_pcall failed with status: 2, error message is: no Java state
[/text]
I’m at a loss here…
Can anyone help me figure out what is happening?
[import]uid: 59229 topic_id: 33861 reply_id: 333861[/import]