Android Device back button causing errors in directors class game application

My application was rejected by the amazon android market because the android device’s back button exits the application and takes the user to the devices home screen and then when the application is relaunched the screen starts to flicker and go black…how to I make the device’s back button go to the previous screen or go to the main menu instead. I have successfully set up back and menu buttons within the application’s screens its the device back button causing issues
thanks in advance [import]uid: 38341 topic_id: 9599 reply_id: 309599[/import]

Try this, I was having the same problem. Put this code in your main lua.

[lua] --------------------------------------------------------------------------------
– Android “restart” Wakeup Code (forces a display update after 250 msec)

– If applicationStart then fire a 250 ms timer.
– After 250 ms, changes the Alpa value of the Current Stage (group)
– This forces a display update to wake up the screen

local function onAndroidSystemEvent( event )

local timerEnd = function()
local t = display.getCurrentStage()
t.alpha = 0.9 – force a display update
timer.performWithDelay( 1, function() t.alpha = 1.0 end ) – wait one frame
end

– Start timer if this is an application start event
if “applicationStart” == event.type then
timer.performWithDelay( 250, timerEnd )
end
end

– Add the System callback event if Android
if “Android” == system.getInfo( “platformName” ) then
Runtime:addEventListener( “system”, onAndroidSystemEvent )
end
[lua] [import]uid: 39088 topic_id: 9599 reply_id: 35024[/import]

Thanks a ton, it works perfectly! [import]uid: 38341 topic_id: 9599 reply_id: 35028[/import]

No problem, glad I could help. [import]uid: 39088 topic_id: 9599 reply_id: 35066[/import]

Neat! This should be stickied or something! [import]uid: 49205 topic_id: 9599 reply_id: 35105[/import]

skalistican6,

Your Wakeup code is very interesting, and I might need to use it =)

While I follow the logic, I am confused on the theory behind this…sure I am missing something obvious.

Why do we need to refresh the screen on application start…if an app is starting, isn’t it refreshing already. Since this is labeled “wakeup”…is this used more for resuming? I have seen ApplicationResume before though…and not sure why we would not use that instead of ApplicationStart.

Hoping someone can clarify…it seems like a great idea…just would like to understand the reason for it.

Thanks. [import]uid: 39506 topic_id: 9599 reply_id: 45224[/import]

@gibsonpa

This is a workaround for build 484. The screen would sleep on restart of an app . The code is from the man Tom. Im not sure if this has been fixed in later builds or not since I am still using 484. If you want to check out the thread where I got this code do a search in the forums for problem with build 484.
JM [import]uid: 39088 topic_id: 9599 reply_id: 45283[/import]