Skip to content

Android

Checked against c1b2fa4 on 2026-11-10. The files it covers are unchanged since.

The Android host draws the render stream with Jetpack Compose and Material 3 and calls the core over JNI (crates/niso-android, built as libniso_android.so). It comes in two parts:

  • hosts/android/niso, an Android library: the engine (Engine.kt), the renderer (NodeView.kt, RenderNode.kt), native controls (Controls.kt), the theme the page sees (Theme.kt) and media (MediaHost.kt). Apps build on it.
  • hosts/android/app, the host app: an activity running one page, plus its home screen widget and notifications.
Terminal window
hosts/android/build.sh # examples/counter on a running emulator or device
hosts/android/build.sh timer # another example
hosts/android/build.sh --app LIB # a native app library (arm64, exports niso_app_main)
hosts/android/build.sh --jvm DIR CLASS # a Java or Kotlin app on the dev.niso.dom binding

With no device attached, the script starts the AVD named in NISO_AVD. NISO_APK_LABEL builds a standalone APK instead (hosts/android/apk.sh), and NISO_ENGINE=porffor compiles the page’s script ahead of time with Porffor (Engines). Setup is in Android apps.

The host runs the page’s event loop on every display frame while it animates (niso_dom_needs_frame), and otherwise only when the user acts, a timer is due, or a worker or native module sends something, so an idle page costs nothing. Pages can import native modules written in Kotlin as niso:<name> (Native modules).

  • Home screen widget: a Glance widget draws the page’s widget.small or widget.medium template, whichever fits (SurfaceWidget.kt).
  • Ongoing notification: while the page has an activity surface, it’s an ongoing notification (Android 16 promotes it to a Live Update). The template maps onto the notification’s fixed slots: first text as the title, a timer as its chronometer, a progress bar, buttons as actions (Surfaces.kt).
  • Media: the page’s media session keeps playing in the background with the system’s media notification (MediaHost.kt).

Wear OS, Android TV and Android Auto are planned, not built (Planned platforms).