Mob.Device.Android (mob v0.6.0)

Copy Markdown View Source

Android-specific device events. Symmetrical with Mob.Device.IOS.

Messages are tagged :mob_device_android:

{:mob_device_android, event}
{:mob_device_android, event, payload}

Subscribe

Mob.Device.Android.subscribe()

Status

Android event surfacing is pending implementation. The Elixir API is stable; subscribing succeeds but no events fire until ProcessLifecycleObserver and ComponentCallbacks2 are wired up in the generated app's Java/Kotlin side. Tracked in PLAN.md under "Native event surface — Batch 1".

Planned events

  • :doze_mode_changed — Doze mode entered/exited (no iOS counterpart)
  • :idle_mode_changed — light idle mode (ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED)
  • :trim_memory with level — ComponentCallbacks2.onTrimMemory(level)
  • :airplane_mode_changedACTION_AIRPLANE_MODE_CHANGED
  • :user_presentACTION_USER_PRESENT (device unlocked)
  • all cross-platform Mob.Device events re-emitted under this tag too

Summary

Functions

Returns a specification to start this module under a supervisor.

Subscribe the calling process to Android-specific device events.

Unsubscribe the calling process.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

subscribe()

@spec subscribe() :: :ok

Subscribe the calling process to Android-specific device events.

unsubscribe()

@spec unsubscribe() :: :ok

Unsubscribe the calling process.