Return to Snippet

Revision: 53153
at November 15, 2011 04:45 by chrisaiv


Initial Code
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;
    }
}

Initial URL
http://mobile.tutsplus.com/tutorials/android/build-a-gps-speedometer-getting-into-air-for-android/

Initial Description
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.

Initial Title
AS3: Exiting Android App

Initial Tags


Initial Language
ActionScript 3