Softkey problem using AIR 2.7 / Android 2.3.3
Hello,
I'm developping an AIR application with FlashDevelop and I use AIR 2.7.
The problem is that I can't detect softkeys on my HTC Sensation... any ideas please ?
Here is my AS code :
package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.display.StageQuality; import flash.desktop.NativeApplication; import flash.desktop.SystemIdleMode; import flash.events.Event; import flash.events.KeyboardEvent; import flash.system.Capabilities; import flash.ui.Multitouch; import flash.ui.MultitouchInputMode; import flash.ui.Keyboard; import artcustomer.mobile.framework.api.Framework; import artcustomer.utils.alert.Alert; public class Main extends Sprite { public static var $pathXML:String; public static var $pathAssets:String; public static var $pathScripts:String; public static var $libraryFonts:Array; public static var $stageWidth:Number; public static var $stageHeight:Number; private var _framework:Framework; public function Main():void { setupParams(); setupGlobalVars(); setupSize(); setupTouch(); this.addEventListener(Event.ADDED_TO_STAGE, added, false, 0, true); } private function added(e:Event):void { this.removeEventListener(Event.ADDED_TO_STAGE, added); this.stage.addEventListener(Event.RESIZE, handleStageResize, false, 0, true); if (Capabilities.cpuArchitecture == "ARM") { NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true); NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleActivate, false, 0, true); NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true); } else { this.stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true); } setupFramework(); } /* * * AppSetup * */ private function setupParams():void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.quality = StageQuality.HIGH; stage.align = StageAlign.TOP_LEFT; } private function setupGlobalVars():void { $pathXML = 'xml/'; $pathAssets = 'assets/'; $pathScripts = 'scripts/'; $libraryFonts = new Array(); } private function setupSize():void { $stageWidth = stage.stageWidth; $stageHeight = stage.stageHeight; } private function setupTouch():void { Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT; } /* * * Framework * */ private function setupFramework():void { _framework = Framework.getInstance(); this.addChild(_framework); } /* * * Listeners * */ private function handleStageResize(e:Event):void { setupSize(); } private function handleActivate(e:Event):void { switch (e.type) { case('activate'): NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE; break; case('deactivate'): NativeApplication.nativeApplication.exit(); break; } } private function handleKeyDown(e:KeyboardEvent):void { Alert.show('Android', e.keyCode.toString(), this, 'Ok'); switch (e.keyCode) { case(Keyboard.MENU): e.preventDefault(); break; case(Keyboard.BACK): e.preventDefault(); NativeApplication.nativeApplication.exit(); break; case(Keyboard.SEARCH): e.preventDefault(); break; } } } }
Thank you for your help !
David
