Package | com.wadedwalker.nativeExtension.app |
Class | public final class AppActivityState |
Inheritance | AppActivityState ![]() |
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The AppActivityState
class provides the means of detecting the application state and
know when it changes. The main attractors for this is being able to save app data on pause or quit
and restore the app data when it resumes or is relaunched from a closed state.
To use this native extension, simply create an instance of the AppActivityState
class, add an event listener for the stateChange
event, and compare the
state
property of the event data to the constants included in this class.
See also
Property | Defined By | ||
---|---|---|---|
![]() [static] [read-only]
Deterimines whether or not this native extension is supported on the device the app is running
on. | AppActivityState |
Method | Defined By | ||
---|---|---|---|
Creates a new AppActivityState instance.
| AppActivityState | ||
![]()
Properly shut down this native extension. | AppActivityState | ||
![]()
Get the current activity state of the application. | AppActivityState |
Event | Summary | Defined By | ||
---|---|---|---|---|
This event is dispatched when a state change has occured in the application. | AppActivityState |
Constant | Defined By | ||
---|---|---|---|
![]() [static]
The final call you receive before your activity is destroyed. | AppActivityState | ||
![]() [static]
Called when the system is about to start resuming a previous activity. | AppActivityState | ||
![]() [static]
Called after your activity has been stopped, prior to it being started again. | AppActivityState | ||
![]() [static]
Called when the activity will start interacting with the user. | AppActivityState | ||
![]() [static]
Called when the activity is becoming visible to the user. | AppActivityState | ||
![]() [static]
Called when the activity is no longer visible to the user, because another activity has been
resumed and is covering this one. | AppActivityState |
![]() | property |
isSupported:Boolean
[read-only] Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Deterimines whether or not this native extension is supported on the device the app is running on.
public static function get isSupported():Boolean
![]() | () | Constructor |
public function AppActivityState()
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Creates a new AppActivityState
instance.
![]() | () | method |
public final function dispose():void
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Properly shut down this native extension.
![]() | () | method |
public final function getAppActivityState():String
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Get the current activity state of the application. The value will be any of the following:
started
, restarted
, resumed
, paused
,
stopped
, and destroyed
.
String — String value representing the current state of the application.
|
![]() | Event |
com.wadedwalker.nativeExtension.app.events.StateChangeEvent
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
This event is dispatched when a state change has occured in the application. The states
are: started
, restarted
, resumed
, paused
,
stopped
, and destroyed
.
This event has the following properties in addition to standard event properties:
Property | Value |
---|---|
state | String value representing the current application activity state. |
![]() | Constant |
public static const DESTROYED:String = destroyed
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The final call you receive before your activity is destroyed. This can happen either because the activity is finishing or because the system is temporarily destroying this instance of the activity to save space.
Note: This state may not happen, so it shouldn't be relied on for knowing if the application has been closed, quit, or crashed. A likely chance of this state change happening is an app playing a video/audio file or high CPU usage like playing a game.
![]() | Constant |
public static const PAUSED:String = paused
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Called when the system is about to start resuming a previous activity.
Note: The most likely time this is called is if the user goes to the home screen or brings up the list of Recent Apps on the device.
![]() | Constant |
public static const RESTARTED:String = restarted
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Called after your activity has been stopped, prior to it being started again.
Note: This state change will occur on, but is not limited to, the following activities:
![]() | Constant |
public static const RESUMED:String = resumed
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Called when the activity will start interacting with the user. At this point your activity
is at the top of the activity stack, with user input going to it. This should always occur
the restarted
state.
Note: This state change will occur on, but is not limited to, the following activities:
![]() | Constant |
public static const STARTED:String = started
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Called when the activity is becoming visible to the user.
Note: This state is highly unlikely to ever occur because the app will have been initialized and started before the native extension would have been able to initialize. Included in case developer wants to check for it anyway.
![]() | Constant |
public static const STOPPED:String = stopped
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one. This may happen either because a new activity is being started, an existing one is being brought in front of this one, or this one is being destroyed.
Note: The most likely case of this state happening is if the user leaves the application by either going to the home screen, switching to a different app through the Recent Apps list, or the app was closed or quit. It should be safe to use this state to know if the application has been closed.
package { import flash.display.Sprite; import com.wadedwalker.nativeExtension.app.AppActivityState; import com.wadedwalker.nativeExtension.app.events.StateChangeEvent; final public class MyAndroidApp extends Sprite { private var _aas:AppActivityState; final public function MyAndroidApp() { _aas = new AppActivityState(); _aas.addEventListner(StateChangeEvent.STATE_CHANGE, _onStageChange); } final private function _onStateChange(e:StateChangeEvent):void { switch (e.state) { case AppActivityState.DESTROYED: // The final call you receive before your activity is destroyed. case AppActivityState.PAUSED: // Called when the system is about to start resuming a previous activity. case AppActivityState.RESTARTED: // Called after your activity has been stopped, prior to it being started again. case AppActivityState.RESUMED: // Called when the activity will start interacting with the user. case AppActivityState.STARTED: // Called when the activity is becoming visible to the user. case AppActivityState.STOPPED: // Called when the activity is no longer visible to the user, because another // activity has been resumed and is covering this one. } } } }