detect back button pressed?
Monkey Targets Forums/Android/detect back button pressed?
| ||
has anyone written code to detect if the user presses the back button? (the arrow facing left, not the home button) |
| ||
During OnUpdate(), do this: [monkeycode] If KeyHit(KEY_ESCAPE) Then ' back arrow was hit EndIf [/monkeycode] |
| ||
thanks |
| ||
It should be noted that the back button on Windows phone will only respond to JoyHit( JOY_BACK ) so I tend to use both. |
| ||
If KeyHit(KEY_ESCAPE) Then ' back arrow was hit EndIf on 4.1/4.2 sleeps the app it seems and returns the user to the home screen as if they pressed the home button, happens on a Nexus 7 (4.2) and S3mini (4.1), doesn't matter what I do inside the IF. |
| ||
oh wait there is the new OnClose and OnBack stuff. I'll look at that |
| ||
Yes, using onBack works great now! |
| ||
So, there's also ExitApp which is called by default when OnBack is called. So new to monkey... so how would you override the code. Would something like this work? if (OnBack()) // do my stuff ExitApp .... function OnBack:void() // add code to ask user if he really wants to quit... ExitApp (and I'm using V69, waiting for V70 release.. :)) |