How to quit an Android App - urgent!
Hi guys,
I'm about to release an Android version of my app. It runs as fast on an Samsung Galaxy S2 - as good as the iPad 2!
When you press the home button, the Application stays open in the background and the music plays. It's annoying for the customer to have to manually
go and exit the app from memory.
I'm using Air 2.7
I found this code online, and put it in the first frame of my timeline, but it get 'syntax errors' on the first 2 lines. Anyone have some code that works?
Thanks,
Matt
if(Capabilities.cpuArchitecture==”ARM”){
NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true); NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true); NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
}
function handleActivate(event:Event):void
{
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
}
function handleDeactivate(event:Event):void
{
NativeApplication.nativeApplication.exit();
}
function handleKeys(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.BACK) {
NativeApplication.nativeApplication.exit();
}
}
