/ Published in: ActionScript 3
Okay, we should now have an app that quits when the user presses the Back or Home keys rather than switching to the background and eating up battery.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import flash.desktop.NativeApplication; import flash.events.KeyboardEvent; import flash.ui.Keyboard; NativeApplication.nativeApplication.addEventListener( KeyboardEvent.KEY_DOWN, handleKeyDown ); function handleKeyDown( e :KeyboardEvent ) :void { switch( e.keyCode ) { case Keyboard.BACK: NativeApplication.nativeApplication.exit(); break; case Keyboard.SEARCH: case Keyboard.MENU: e.preventDefault(); break; } }
URL: http://mobile.tutsplus.com/tutorials/android/build-a-gps-speedometer-getting-into-air-for-android/