/ Published in: ActionScript 3

For your Air for Android application to properly close you need to define some handlers and respond to them.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Check if we are on a Android / iPhoney device. if(Capabilities.cpuArchitecture=="ARM") { NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true); NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true); NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true); } private function handleActivate(event:Event):void { NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE; } private function handleDeactivate(event:Event):void { NativeApplication.nativeApplication.exit(); } private function handleKeys(event:KeyboardEvent):void { if(event.keyCode == Keyboard.BACK) NativeApplication.nativeApplication.exit(); }
Comments
