Skip to main content
Pouradam
Inspiring
August 11, 2013
Answered

Disable Default function of "Back" button for Android.

  • August 11, 2013
  • 2 replies
  • 1547 views

Hi there!

I have tried SO MANY methods to PREVENT the default function of Back button in Android but no success

This is one of the codes I have used with no success:

stage.addEventListener(KeyboardEvent.KEY_UP, optionsKey, false, 0, true);

function optionsKey(ke:KeyboardEvent):void
{

      if (ke.keyCode == Keyboard.BACK)
      {

            ke.preventDefault();
            ke.stopImmediatePropagation();

         

          //Do my own code below...

     }

}

I am using Flash Cs6 , Air 3.2 for Android , Testing it on LG Google nexus 4.

When I use the flash simulator, it works fine! Means the Back Button, let the App go back to previous step (as I expect it to do)

But after I publish the apk (Aspect ratio: Auto , Auto orientation , Render mode: GPU), as soon as I press BACK, it minimize my app!

(means when i press the Back button on my phone, the App minimize down (not close!). when I re-activate it/click on it, I see the app has actually gone one step BACK (as I programmed and expected), but I just CANT STOP the default action of MINIMIZING/De-activating my app after pressing Back button.

Anyone have any "Fla" file that I can see it in ACTION please?!

Because I have used many-many codes and no success yet

thanks and looking forward for your any kind of hlep...

Message was edited by: Pouradam

This topic has been closed for replies.
Correct answer Pouradam

I got my own answer thanks to myself!!

in above code .KEY_UP should be changed to .KEY_DOWN.

simple!

2 replies

Pouradam
PouradamAuthorCorrect answer
Inspiring
August 12, 2013

I got my own answer thanks to myself!!

in above code .KEY_UP should be changed to .KEY_DOWN.

simple!

Pouradam
PouradamAuthor
Inspiring
August 12, 2013

No answer???? ....