Skip to main content

AndroidLifecycle

Kindclass
Packageandroid.platform
Full nameandroid.platform.AndroidLifecycle
Sourcesource/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​

NameTypeStaticDefaultNotes
onEventFlxTypedSignal<String->Void>yes—property (get, never) · Every lifecycle event: onCreate/onStart/onResume/onPause/onStop/onRestart/onDestroy.
onResumeFlxSignalyes—property (get, never) · The Activity became visible and interactive again.
onPauseFlxSignalyes—property (get, never) · The Activity is no longer in the foreground (backgrounded).
onStopFlxSignalyes—property (get, never) · The Activity is fully hidden.
onCreateFlxSignalyes—property (get, never) · The Activity is being created (cold start).
onDestroyFlxSignalyes—property (get, never) · The Activity is being destroyed.
inForegroundBoolyestrueproperty (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).

ParameterTypeDefault
autoPause (optional)Booltrue

View source

Internals​

Private / internal members
FieldTypeStatic
initializedBoolyes
onResumeSignalFlxSignalyes
onPauseSignalFlxSignalyes
onStopSignalFlxSignalyes
onCreateSignalFlxSignalyes
onDestroySignalFlxSignalyes
pausedByLifecycleBoolyes
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