Package | com.distriqt.extension.application.events |
Class | public class ApplicationStateEvent |
Inheritance | ApplicationStateEvent ![]() |
This event is used to dispatch application state event changes, such as application deactivations, and background / foreground events.
BACKGROUND
and FOREGROUND
events are very useful
in situations where you aren't interested in the loss of focus of your AIR
stage but that the entire application has been moved to the background
(or foreground).
The difference here is obvious when your application launches native activities or displays dialogs, or even in response to the iOS control centre overlay. In these situations the normal AIR DEACTIVATE event will fire even though your AIR application is still running in the foreground.
It is useful to be able to determine the difference between these cases and this is the intent of these events.
Update April 2017: Apple has made the determining of the reason for deactivate/background event (lock or home) unsupported and will now lead to AppStore rejection. Hence this functionality is no longer available on iOS. iOS will continue to dispatch the deactivate event however will always report the home button was pressed.
Property | Defined By | ||
---|---|---|---|
code : String
The code associated with this event, see the CODE prefixed
options in this class. | ApplicationStateEvent | ||
description : String
Unused
| ApplicationStateEvent |
Method | Defined By | ||
---|---|---|---|
ApplicationStateEvent(type:String, code:String, description:String, bubbles:Boolean = false, cancelable:Boolean = false)
Constructor
| ApplicationStateEvent | ||
clone():Event [override] | ApplicationStateEvent |
Constant | Defined By | ||
---|---|---|---|
ACTIVATE : String = applicationstate:activate [static]
Similar to the standard AIR Event.ACTIVATE event. | ApplicationStateEvent | ||
BACKGROUND : String = applicationstate:background [static]
This event is dispatched when your application enters the background rather than a deactivated state. | ApplicationStateEvent | ||
CODE_HOME : String = deactivate:home [static]
This code occurs when a normal application deactivation occurs, by
pressing the home button or by switching between applications. | ApplicationStateEvent | ||
CODE_LOCK : String = deactivate:lock [static]
This code occurs when the phone screen is disabled and the phone
enters it's 'lock' power saving state . | ApplicationStateEvent | ||
DEACTIVATE : String = applicationstate:deactivate [static]
Dispatched when the application is deactivated. | ApplicationStateEvent | ||
FOREGROUND : String = applicationstate:foreground [static]
This event is dispatched when your application returns from a background state and enters the foreground
This has the advantage over the ACTIVATE event that it isn't dispatched when your AIR stage gains focus
after a dialog or other activity was closed. | ApplicationStateEvent |
code | property |
public var code:String
The code associated with this event, see the CODE
prefixed
options in this class.
This value is currently invalid on iOS due to Apple policy changes
See also
description | property |
public var description:String
Unused
ApplicationStateEvent | () | Constructor |
public function ApplicationStateEvent(type:String, code:String, description:String, bubbles:Boolean = false, cancelable:Boolean = false)
Constructor
Parameterstype:String | |
code:String | |
description:String | |
bubbles:Boolean (default = false )
| |
cancelable:Boolean (default = false )
|
clone | () | method |
override public function clone():Event
ReturnsEvent |
ACTIVATE | Constant |
public static const ACTIVATE:String = applicationstate:activate
Similar to the standard AIR Event.ACTIVATE
event.
BACKGROUND | Constant |
public static const BACKGROUND:String = applicationstate:background
This event is dispatched when your application enters the background rather than a deactivated state.
This has the advantage over the DEACTIVATE event (including the normal AIR Event) that it isn't dispatched when a dialog or another activity is launched from your application, where the AIR stage may lose focus but your application is still in the foreground.
CODE_HOME | Constant |
public static const CODE_HOME:String = deactivate:home
This code occurs when a normal application deactivation occurs, by pressing the home button or by switching between applications.
CODE_LOCK | Constant |
public static const CODE_LOCK:String = deactivate:lock
This code occurs when the phone screen is disabled and the phone enters it's 'lock' power saving state . This is either from a screen time out or by the user pressing the power button.
DEACTIVATE | Constant |
public static const DEACTIVATE:String = applicationstate:deactivate
Dispatched when the application is deactivated. This is an alternative of
the AIR Event.DEACTIVATE
which will contain more information
about whether the application screen was turned off in the deactivation
process.
FOREGROUND | Constant |
public static const FOREGROUND:String = applicationstate:foreground
This event is dispatched when your application returns from a background state and enters the foreground
This has the advantage over the ACTIVATE event that it isn't dispatched when your AIR stage gains focus after a dialog or other activity was closed. Instead it is only dispatched if your application was minimised and is now returning to the foreground.