When an application is running on an Android device, there is a good chance that a user session can be interrupted by a telephone call, or some other unforeseen event. When a situation like this occurs, we should consider whether it may be appropriate to exit the application and free up system resources for other tasks.
We will listen to the application to fire a deactivate event and exit the application in response:
1. To begin, we will need to import the following classes into our application:
import flash.desktop.NativeApplication: import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event;
2. We must register an event listener of type
Event.DEACTIVATE
upon ourNativeApplication.nativeApplication
object. This event will fire in response to the application losing focus on the device in the event of a telephone call or some other interruption:protected...