Skip to main content

AndroidPlatform

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

Facade for the Phoenix Android platform layer.

Call AndroidPlatform.init() once at startup (Main.hx does this) and the whole native layer becomes available through the dedicated modules:

  • AndroidMedia Media3 session/service, MediaStyle notification, audio focus
  • AndroidDisplay resolution/DPI/orientation/refresh rate/cutouts, immersive fullscreen
  • AndroidSystem memory pressure, battery, wake lock, process-death recovery
  • AndroidGamepad controller info + connection events
  • AndroidHardwareInput volume keys as bindable game input
  • AndroidHaptics vibration
  • AndroidStorage SAF document picker + content:// URIs
  • AndroidIntents URLs, settings, file sharing
  • AndroidNotification simple notifications
  • AndroidLifecycle Activity lifecycle signals
  • AndroidDiscord presence through the media session

On non-Android targets every module compiles to safe no-ops, so none of the desktop/web/Flash/HashLink/iOS builds depend on Android code.

Public fields​

NameTypeStaticDefaultNotes
activeBoolyesfalseproperty (default, null) · True once init() completed on Android; always false elsewhere.

Public methods​

init​

static function init(autoPauseAudio:Bool = true, watchDisplay:Bool = true):Void

Boots the platform layer: registers the JNI bridge, starts lifecycle handling, controller watching and memory-pressure responses.

@param autoPauseAudio pause/resume music when the Activity backgrounds @param watchDisplay start receiving display change events

ParameterTypeDefault
autoPauseAudio (optional)Booltrue
watchDisplay (optional)Booltrue

View source

Internals​

Private / internal members
FieldTypeStatic
initializedBoolyes
deepLinkDrainTimerFlxTimeryes
Method
static function releaseCaches():Void
static function flushSave():Void