AndroidLifecycle
| Kind | class |
| Package | android.platform |
| Full name | android.platform.AndroidLifecycle |
| Source | source/android/platform/AndroidLifecycle.hx |
Exposes Android Activity lifecycle events to Haxe and keeps gameplay/audio state in sync when the app loses or regains focus.
Signals are re-exposed here for convenience; they are the same objects as
the ones on AndroidBridge.
Public fields
| Name | Type | Static | Default | Notes |
|---|---|---|---|---|
onEvent | FlxTypedSignal<String->Void> | yes | — | property (get, never) · Every lifecycle event: onCreate/onStart/onResume/onPause/onStop/onRestart/onDestroy. |
onResume | FlxSignal | yes | — | property (get, never) · The Activity became visible and interactive again. |
onPause | FlxSignal | yes | — | property (get, never) · The Activity is no longer in the foreground (backgrounded). |
onStop | FlxSignal | yes | — | property (get, never) · The Activity is fully hidden. |
onCreate | FlxSignal | yes | — | property (get, never) · The Activity is being created (cold start). |
onDestroy | FlxSignal | yes | — | property (get, never) · The Activity is being destroyed. |
inForeground | Bool | yes | true | property (default, null) · True between onResume and onPause. |
Public methods
init
static function init(autoPause:Bool = true):Void
Starts listening to lifecycle events. When autoPause is true the
engine automatically pauses/resumes music when the Activity
backgrounds/foregrounds (Flixel's own focus handling covers most of
this; the hook exists for targets where it does not fire reliably).
| Parameter | Type | Default |
|---|---|---|
autoPause (optional) | Bool | true |
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
initialized | Bool | yes |
onResumeSignal | FlxSignal | yes |
onPauseSignal | FlxSignal | yes |
onStopSignal | FlxSignal | yes |
onCreateSignal | FlxSignal | yes |
onDestroySignal | FlxSignal | yes |
pausedByLifecycle | Bool | yes |
| Method |
|---|
static inline function get_onEvent():FlxTypedSignal<String->Void> |
static inline function get_onResume():FlxSignal |
static inline function get_onPause():FlxSignal |
static inline function get_onStop():FlxSignal |
static inline function get_onCreate():FlxSignal |
static inline function get_onDestroy():FlxSignal |
static function pauseAudio():Void |
static function resumeAudio():Void |