Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

How to quit Andoid-app instead of suspending

Explorer ,
Apr 25, 2011 Apr 25, 2011

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!

TOPICS
Development
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2011 Apr 25, 2011

Use this:

stage.addEventListener(Event.DEACTIVATE, deactivateHandler);
function deactivateHandler(event:Event):void
{
    NativeApplication.nativeApplication.exit();
}

Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2011 Apr 26, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2011 Apr 26, 2011

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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2011 Apr 26, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 26, 2011 Apr 26, 2011

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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2011 Apr 26, 2011
LATEST

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines