Skip to main content
October 4, 2012
Question

Menu Back keys not recognized when testing on Device

  • October 4, 2012
  • 3 replies
  • 518 views

Helo,

I've been searching over the web, without success finding a solution,

hope to find an answer here.

I'm new to Air for Android Dev, so i found and downloaded a nice sample app to learn from.

Here's a relevant code:

import flash.events.KeyboardEvent;

import flash.ui.Keyboard;

stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey);

function onKey(e:KeyboardEvent):void {

       if(e.keyCode == Keyboard.MENU) {

            e.preventDefault();

            trace("menu");

       }

}

Everithing was fine, the code was working at simulator, and on my device,

so I created a new "Air for Android" document, and wrote the very same code just to test.

After publishing my new document (very same to the one I've downloaded), it stoped recognizing KEY_DOWN event on my device,

but when publishing to a simulator everything is fine and working.

Hope that someone here has an idea of what could be the reason for this problem,

Aline.

This topic has been closed for replies.

3 replies

October 7, 2012

ok...

it didn't work because of "unable to connect to the debugger" message.

if enyone get this problem the solution is to go into air for android settings,

deployment tub, check "debug" radio button, select "local area connection",

then publish and everything is working fine,

apart trace statements at the output window...

Inspiring
October 6, 2012

looks ok to me.

try this instead:

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN,onKey);

October 7, 2012

thank for your reply,

tried that, didn't help...

i think it happens because of the "unable to connect to the debugger" message on my device,

i"ll try to solve that and will update this post if that fixed this issue...