#android #ui-toolkit #jni #java #environment #robius #os-android-apis

robius-android-env

Rust access to Android state (native Java objects) managed by UI toolkits

2 unstable releases

new 0.2.0 Oct 31, 2024
0.1.0 May 20, 2024

#418 in GUI

Download history 1/week @ 2024-07-13 5/week @ 2024-08-10 4/week @ 2024-08-17 5/week @ 2024-08-24 2/week @ 2024-08-31 20/week @ 2024-09-14 21/week @ 2024-09-21 41/week @ 2024-09-28 28/week @ 2024-10-05 13/week @ 2024-10-12 51/week @ 2024-10-26

97 downloads per month
Used in 4 crates

MIT license

9KB

robius-android-env

Latest Version Docs Project Robius Matrix Chat

This crate provides easy Rust access to Android state (native Java objects) managed by UI toolkits.

Usage of this crate

This crate exists for two kinds of downstream users:

  1. The UI toolkit that exposes its key internal states that hold the current Android activity being displayed and the Java VM / JNI environment. Either the UI toolkit or the app itself should set these states on startup, either by using ndk-context or by activating a feature for a specific UI toolkit.
  2. The platform feature "middleware" crates that need to access the current activity and JNI environment from Rust code in order to interact with the Android platform.

Supported UI toolkits

  • Makepad: enable the makepad Cargo feature.
  • UI toolkits compatible with ndk-context: supported by default.
  • Others coming soon! (in the meantime, see below)

Usage of this crate for other UI toolkits

For any other UI toolkits that support ndk-context, you don't need to enable any cargo features. However, either your application code or the UI toolkit must manually initialize the Android context owned by ndk-context, i.e., by invoking initialize_android_context(). Some UI toolkits automatically do this for you, typically via the ndk-glue crate.

Dependencies

~1–12MB
~83K SLoC