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

robius-android-env

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

1 unstable release

0.1.0 May 20, 2024

#362 in GUI

Download history 196/week @ 2024-05-20 14/week @ 2024-05-27

210 downloads per month
Used in 2 crates

MIT license

9KB
50 lines

robius-android-env

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, specifically using set_vm() and set_activity_getter() functions.
  2. The Rust platform feature crates that need to access the current activity and JNI environment in order to interact with the Android platform.

Supported UI toolkits

  • Makepad: enable the makepad Cargo feature.
  • Others coming soon! (in the meantime, see below)

Usage of this crate for other UI toolkits

For any other UI toolkits not listed above, you don't need to enable any cargo features. Instead, your application code must manually provide two key states:

  • a reference to the current Android activity.
  • a reference to the current Java VM instance (and JNI environment).

This can be achieved by doing the following:

Dependencies

~1–13MB
~100K SLoC