Copy link to clipboard
Copied
I made an app using air 2.6.
When I hit the quit-button on my Android-phone and later on I restart the app, it continues where I quit it, but I want to totally restart from the beginning.
I looked over the internet for hours, but I can't find any solution ... I found this: NativeApplication.nativeApplication.exit(); ... but can't get it to work, hope someone can help, thanks!
Copy link to clipboard
Copied
Use this:
stage.addEventListener(Event.DEACTIVATE, deactivateHandler);
function deactivateHandler(event:Event):void
{
NativeApplication.nativeApplication.exit();
}
Chris
Copy link to clipboard
Copied
Thanks Chris!
But now I get these two errors:
Access of undefined property NativeApplication
Definition flash.desktop:NativeApplication could not be found.
Do I have to manually install this library? did some googling, but don't know where to find it.
Copy link to clipboard
Copied
Are you using Flex? If so you need to turn off the persistNavigationState. By default it is true.
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
persistNavigatorState="false"
Copy link to clipboard
Copied
No, not using Flex, just Flash/FlashDevelop.
For iPhone it can be done by adding UIApplicationExitsOnSuspend in the descriptor file, but it gives an error when compiling an apk-file.
Copy link to clipboard
Copied
Did you import the correct class?
import flash.desktop.NativeApplication
I assume you did by the error message, but double check! I have my air apps exit when you hit the android back button on the first screen and it always works for me. I set up a listener for the native key and
NativeApplication.nativeApplication.exit();
Copy link to clipboard
Copied
I did the import, but then I get the error ... do I have to download them somewhere separately? where should they be on my harddisk?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now