Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Handle back, menu and home button on Android

New Here ,
Aug 15, 2011 Aug 15, 2011

I'm developing an Adobe Air 2.6 app for android tablets (using ActionScript 3.0 and Flash Builder 4.5).

I want to know how can I handle user back key press.

I read somewhere there is a specific Adobe Air SDK for Android, but I read it on a forum from 2010.

Any advice?

TOPICS
ActionScript
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 16, 2011 Aug 16, 2011
LATEST

A simple google search did the trick, first result:

http://www.unitedmindset.com/jonbcampos/2010/09/17/air-for-android-home-menu-back-and-search-buttons/

private function _onAddedToStage(event:Event):void {
    //removes listener
    removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
}

private function _onKeyDown(event:KeyboardEvent):void {
    if(event.keyCode == Keyboard.BACK) {
        event.preventDefault();
                _text.appendText("\nBack Pressed");
    } else if(event.keyCode == Keyboard.MENU) {
        event.preventDefault();
        _text.appendText("\nMenu Pressed");
    } else if(event.keyCode == Keyboard.SEARCH) {
        event.preventDefault();
        _text.appendText("\nSearch Pressed");
    }
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines