Skip to main content

AndroidBridge

Kindclass
Packageandroid.platform
Full nameandroid.platform.AndroidBridge
Sourcesource/android/platform/AndroidBridge.hx

Central JNI bridge between the Haxe engine and the Phoenix Android native layer (source/android/src/quack/fnf/phoenix/android/*.java).

Java pushes events through onAndroidEvent(event, arg) and storage results through handleStorageResult(...); this class demultiplexes them into the typed signals exposed by the android.platform.* modules.

Everything here is safe to reference on every platform: outside of Android the signals simply never fire and the bound helpers no-op.

Public fields​

NameTypeStaticDefaultNotes
availableBoolyes—property (get, never) · True when running on a real Android build with the native layer available.
onLifecycleEventFlxTypedSignal<String->Void> = new FlxTypedSignal<String->Void>()yes—Lifecycle event names: onCreate/onStart/onResume/onPause/onStop/onRestart/onDestroy.
onLowMemoryFlxSignalyesnew FlxSignal()Fired on Activity#onLowMemory.
onTrimMemoryFlxTypedSignal<Int->Void> = new FlxTypedSignal<Int->Void>()yes—Fired on Activity#onTrimMemory with the trim level.
onMediaPlayFlxSignalyesnew FlxSignal()—
onMediaPauseFlxSignalyesnew FlxSignal()—
onMediaStopFlxSignalyesnew FlxSignal()—
onMediaNextFlxSignalyesnew FlxSignal()—
onMediaPreviousFlxSignalyesnew FlxSignal()—
onMediaSeekFlxTypedSignal<Float->Void> = new FlxTypedSignal<Float->Void>()yes—Seek request from the system media UI, position in milliseconds.
onFocusChangedFlxTypedSignal<String->Void> = new FlxTypedSignal<String->Void>()yes—Audio focus changes: "gain", "loss", "lossTransient", "duck".
onGamepadConnectedFlxTypedSignal<Int->Void> = new FlxTypedSignal<Int->Void>()yes—Gamepad device id connected.
onGamepadDisconnectedFlxTypedSignal<Int->Void> = new FlxTypedSignal<Int->Void>()yes—Gamepad device id disconnected.
onGamepadChangedFlxTypedSignal<Int->Void> = new FlxTypedSignal<Int->Void>()yes—Gamepad device id changed (configuration update).
onHardwareKeyFlxTypedSignal<Int->Bool->Void> = new FlxTypedSignal<Int->Bool->Void>()yes—Hardware key events (volume keys as input): keyCode, isDown.
onDisplayChangedFlxSignalyesnew FlxSignal()Display configuration changed (rotation/refresh/mode).
onDeepLinkFlxTypedSignal<String->Void> = new FlxTypedSignal<String->Void>()yes—Incoming phoenix:// deep link (or any VIEW data URI).
onIntentActionFlxTypedSignal<String->Void> = new FlxTypedSignal<String->Void>()yes—Non-launch intents that carried no data (informational).
onPermissionsResultFlxTypedSignal<String->Void> = new FlxTypedSignal<String->Void>()yes—Results of runtime permission requests (CSV of granted permissions).
onRecoveryStateFlxTypedSignal<String->Void> = new FlxTypedSignal<String->Void>()yes—Recovery state blob restored after a warm restart.
onStorageResultFlxTypedSignal<AndroidStorageResult->Void> = new FlxTypedSignal<AndroidStorageResult->Void>()yes—SAF picker results.

Public methods​

new (constructor)​

function new()

Explicit constructor: classes built by lime's JNISafety autoBuild macro don't get the compiler-generated default one, so new AndroidBridge() would fail to type without this.

View source

ensureRegistered​

static function ensureRegistered():Void

Registers this dispatcher with the Java side. Called automatically by AndroidPlatform.init(); safe to call multiple times.

View source

onAndroidEvent​

function onAndroidEvent(event:String, arg:String):Void

Only compiled when #if android.

ParameterTypeDefault
eventString—
argString—

View source

handleStorageResult​

function handleStorageResult(requestCode:Int, resultCode:Int, uri:String, name:String, size:Float, bytes:Dynamic):Void

Only compiled when #if android.

ParameterTypeDefault
requestCodeInt—
resultCodeInt—
uriString—
nameString—
sizeFloat—
bytesDynamic—

View source

static function watchDeepLink(listener:String->Void):Void

Only compiled when #if android.

Subscribes to onDeepLink and registers the subscription with the delivery tracker. Use this instead of onDeepLink.add(...) so a buffered cold-start deep link can be confirmed delivered to you; the bridge immediately tries to drain any pending link.

ParameterTypeDefault
listenerString->Void—

View source

static function drainPendingDeepLink():Bool

Only compiled when #if android.

Pulls the buffered cold-start deep link from the native layer and delivers it to onDeepLink subscribers. The native buffer is only cleared after confirmed delivery, so the link keeps retrying until something subscribes via watchDeepLink. Returns true when there is nothing (left) to deliver, false while a link is still waiting for a subscriber.

View source

Internals​

Private / internal members
FieldTypeStatic
registeredBoolyes
instanceAndroidBridgeyes
deepLinkListenersIntyes
_getPendingDeepLinkDynamicyes
_clearPendingDeepLinkDynamicyes
RESULT_OKIntyes
Method
static inline function get_available():Bool
static function getPendingDeepLink_jni():String
static function clearPendingDeepLink_jni():Void