Created
February 21, 2012 16:14
-
-
Save jgranick/1877209 to your computer and use it in GitHub Desktop.
How to override the back button on Android (NME recipe)
Anyone know if this works in latest NME? Doesn't work for me.
Upgrade to openfl 1.0.4 works.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The default behavior for the back button on Android is to minimize your application. Sometimes you may wish to trigger an event before the application goes to the background, or you may wish to close your application entirely.
In NME 3.2, you will need to handle the KEY_UP event for the back button. On older versions you may have to handle both KEY_DOWN and KEY_UP events.
When you call "stopPropagation" or "stopImmediatePropagation" it will cancel the default behavior for the button. Use this to disable minimizing entirely, or in this sample, I am exiting the application instead.
If you wanted to save or perform another behavior before minimizing, you could allow propagation... just handle the event then it will minimize afterwards.