Skip to main content
Participating Frequently
May 24, 2011
Question

Flash Debug Android Back Button Feature

  • May 24, 2011
  • 1 reply
  • 814 views

So others may not waste half a day going nowhere....

I use the Android Device's own back button to help navigate through my apps, listening for the KeyboardEvent preventing default when back is triggered.

When testing using 'Android deployment type' as 'Debug' the Androids 'Back' button doesn't trigger a KeyboardEvent when first used.

It sends the device back to the Home screen and it appears the app has exited (no active apps).

Going back into the app it goes back to the screen where you were (as though it was active) and the app and back button works fine from then on.

If using 'Android deployment type' as 'Device release' the Androids 'Back' button works fine straight away.

A somewhat annoying feature....

I use Flash CS5.

Cheers

Eddie

This topic has been closed for replies.

1 reply

Participant
June 13, 2011

I'm also developing an app for Android phone and I tried to overwrite the closing command of the back-button on the Android Phone. It took me some time to find out this was done with the very simple command event.preventDefault(); .

The complete code would be:

package {

import flash.desktop.NativeApplication;

import flash.events.KeyboardEvent;

import flash.ui.Keyboard;

public class Main {

public function Main() {

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);

}

private function handleKeys(event:KeyboardEvent):void {

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

event.preventDefault();

//here you can type what you want to happen instead of closing down the app

}

}

}

}

Also to respond to you Eddie... I did not have the same problem as you had, however I could find my application in 'Cached applications' on my Nexus S. This is where I could see it was still running.

To my knowledge it is not possible to overwrite the home-button command. Please correct me if I'm wrong ;-)

Anyways... good luck programming all