I have a “key” listener for the Android version of our app, and that works as it should. I originally added a check to see if the device was a Nook and if so I would NOT add the key listener, but now have the listener for Nook as well.
As far as I am aware this should leave the “n” button to use it’s default functionality. Since we do not have a status bar displayed, this would mean exiting the app, which is what happens.
However if I use the “n” button to exit, when the app resumes there is no sound at all. I have to use the suspend and resume using the power button, and then the sound returns.
Here is the code I am using for my key event:
local AndroidKeyEvent = function( event )
local keyname = event.keyName
if (event.phase == "up" and (keyname=="back" or keyname=="menu")) then
if keyname == "menu" then
elseif keyname == "back" then
if storyboard.getCurrentSceneName() == "creditScreen" or storyboard.getCurrentSceneName() == "scoreScreen" or storyboard.getCurrentSceneName() == "settingsScreen" then
storyboard.purgeScene("levelSelect")
storyboard.gotoScene("levelSelect", "crossFade", 1000)
end
return true
elseif keyname == "search" then
end
end
end
if system.getInfo( "platformName" ) == "Android" then
Runtime:addEventListener( "key", AndroidKeyEvent )
end
My systemEvent function is:
local function onSystemEvent( event )
if event.type == "applicationSuspend" or event.type == "applicationExit" then
if not isNook then
audio.pause()
end
elseif event.type == "applicationResume" or event.type == "applicationStart" then
audio.resume()
if event.type == "applicationResume" then
if \_G.isNook then
display.currentStage.alpha = 0.9
-- Force invalidate 1 second after resume
timer.performWithDelay( 1000, function()
display.currentStage.alpha = 1.0
end)
end
end
end
end
As you can see there is an audio.pause() in suspend/exit and an audio.resume() in resume/start. However I have disabled the audio.pause() on Nook, while leaving the audio.resume() in all cases. Yet the bug persists.
Does anyone have any suggestions on what is going wrong?
Thanks [import]uid: 84115 topic_id: 32927 reply_id: 332927[/import]