Skip navigation
Currently Being Moderated

Air for Android - how to handle back button?

Jun 16, 2010 7:07 PM

I have two questions:

1.  Where is the Adobe Air for Android (or Flash for Android) or Adobe sanctioned mobile development forum?

2. I am developing a Flash/AS3 app for Android.  How can I handle the back button to go back within my own application when appropriate?

 
Replies
  • Currently Being Moderated
    Sep 21, 2010 4:44 AM   in reply to LisaMStump

    1) You can register for Pre Release programm (https://prerelease.adobe.com/) and get the AIR SDK for the Android.

    2) The Back, Menu, Search button works with Keyboard Event. You can add the Key Event to the stage and Check the keyCode with the Keyboard class constance like, Keyboard.BACK, Keyboard.MENU, Keyboard.SEARCH.

     

    I hope this answers your question.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 21, 2010 10:45 AM   in reply to ShaileshMak

    My code is working insofar as the menu button gets captured as well as the back button.. but I can only see my back button is function right before it goes to the previous application running on my nexus 1.  I even added the uses permission FORCE_BACK.  Please advise if this is possible or reliable on a range of devices. Thanks!

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 21, 2010 1:28 PM   in reply to LisaMStump

    Thanks Lisa!  It works great.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 28, 2011 9:27 AM   in reply to LisaMStump

    I am not getting the default behavior to be overriden -- I am trying to prevent the back button from popping the view by default (I have a Samsung Charge, FB 4.5, Windows).  It gets into the key handler, but the instructions appear to be ignored:

     

    protected function onKeyDown (event:KeyboardEvent):void {

      event.preventDefault();

      event.stopImmediatePropagation();

    }

     

    and I registered the listener with priority 0 (even tried true and false for useCapture, to see if for some reason it was the listener order), but it's still doing the default behavior of popping the view.

     

    Any thoughts about why this is not working?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 28, 2011 9:46 AM   in reply to JonKaye

    I figured it out, though I don't know why the key handler was not working.

     

    The View class has an event "backKeyPressed", so I can put the preventDefault() and stop propagation there.  I don't need all the key listener stuff and such.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2012 9:17 AM   in reply to LisaMStump

    I wrote a small tutorial on this article here: http://www.grindheadgames.com/handling-button-air-android I hope someone finds it useful.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points