Crate makepad_android_state

source ·
Expand description

The crate responsible for holding Makepad’s Android-specific context states.

These two states are:

  1. The JavaVM instance initialized by the JNI layer.
  • This cannot be set by foreign code outside this crate, as it is only ever set once during the lifetime of the app process.
  1. The current Makepad Activity instance.
  • This can be set by foreign code outside this crate, as the underlying Android platform may tear down and reconstruct the activity instance multiple times during the app’s lifetime.
  • However, for safety reasons, we only permit a single caller to obtain the private “set_activity” function, which ensures that only the internal Makepad framework can set the activity instance.

§Usage

You probably want to use the robius-android-env crate instead of using this crate directly.

External users of this crate should only care about two functions:

  1. get_java_vm(): returns a pointer to the JavaVM instance, through which you can obtain the JNI environment.
  2. get_activity(): returns a pointer to the current Makepad Activity instance.

The other functions are intended for Makepad-internal use only, and will not be useful for external users.

Functions§

  • Returns a raw pointer to the main Makepad Activity instance.
  • Returns a raw pointer to the JavaVM instance initialized by the JNI layer.