Closing the Application

0
138

If another application is selected, yours is moved to the background but continues to play and does not close. Typically, NativeApplication dispatches an exiting event when it starts the closing process. You can register for that event and be prepared to act quickly according to your application needs:

import flash.desktop.NativeApplication;
import flash.events.Event;
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExit);
function onExit(event:Event):void {
// save application’s current state
}

However, the Android OS may choose to terminate background processes immediately if RAM is needed. In some cases, such as receiving a phone call, there is no guarantee that NativeApplication will have a chance to dispatch the exiting event before being shut down. It is therefore a good practice to save critical data often while the application is active.

The Android OS closes applications that were inactive the longest first. If you want to immediately shut down a particular application, select Settings→Applications→Manage applications→Running, click the desired icon, and press “Force stop.” You can also use third-party task killer applications, which conveniently display all the applications currently
running in one selection.

The Android UX guidelines recommend using the back or home button as an exit button. But you may choose to shut down your AIR application via code when it moves to the background, or make it a user option while it is running to run the following method:

NativeApplication.nativeApplication.exit();