Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?