Skip to main content
Participant
August 20, 2013
Question

System 'Back' button in Android 4.3

  • August 20, 2013
  • 1 reply
  • 977 views

My Nexus 4 was recently updated to Android 4.3. The below code to control the system Back button worked with the previous versions of Android 4.2 and below. However, now my phone has been updated to 4.3, the Back button simply closes the app. The Back button works perfectly in the Simulator. Here is the code:

stage.addEventListener(KeyboardEvent.KEY_UP, backButton);

private function backButton(e:KeyboardEvent):void

{

 

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

                                             e.preventDefault();

                                             e.stopImmediatePropagation();

                                             clickClose(null); //Brings up a splash screen to confirm whether to close the app

     }

}

Has anyone else had this problem or is there a solution to get it to work?

Thanks,

hp

This topic has been closed for replies.

1 reply

Adobe Employee
August 21, 2013

Hi,

I tried with the above code mentioned but it working fine on nexus7(v4.3). Could you please share the AIR SDK version you are using so that I can give it a try again? Are you albe to reproduce the issue on any other device having 4.3 version?

Also, I request you to try latest AIR SDK available at http://www.adobe.com/devnet/air/air-sdk-download.html if not using already.

Regards,

Nimit

5lampsdevAuthor
Participant
August 21, 2013

Thanks for the reply Nimit.

I have tried in the latest Adobe AIR 3.8.0.870

The preventDefault seems to work sometimes and not others. I have tried an example app with just a simple back button test (like the above code) and that works so it must be something is conflicting in my app. Its just weird how it works in the Simulator and Android 4.2 but not now?

I'll post here if I manage to get it to work.

5lampsdevAuthor
Participant
August 21, 2013

Ok so I think I have found what the issue is.

When I go from one panel/page to another, if I touch the screen the preventDefault works. However, if I click the system 'Back' button before touching the screen, the app closes.

Is there anyway to fix this? Would I have to put:

stage.focus = stage;

everytime the app changes panel or page?