Mob.Device.Android (mob v0.9.7)

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

The :app lifecycle events (:will_resign_active, :did_become_active, :did_enter_background, :will_enter_foreground, :will_terminate) are re-emitted here as {:mob_device_android, event}, as Mob.Device.IOS gets them on iOS; see Mob.Device for when each fires. Nothing Android-specific fires yet: the events below need ComponentCallbacks2 and broadcast receivers in the generated app's 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_changed — ACTION_AIRPLANE_MODE_CHANGED
  • :user_present — ACTION_USER_PRESENT (device unlocked)
  • the remaining cross-platform Mob.Device events re-emitted under this tag

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.