Skip to main content

Crate jni_min_helper

Crate jni_min_helper 

Source
Expand description

Minimal helper for jni-rs, supporting dynamic proxies, Android dex embedding, permission request and broadcast receiver. Used for calling Java code from Rust.

Version 0.4.x of this crate can be used with jni 0.22.x.

This crate uses ndk_context::AndroidContext on Android, usually initialized by android_activity. Examples for Android are provided in the crate page.

Please make sure you are viewing documentation generated for your target.

Structs§

BroadcastReceiver
Handles android.content.BroadcastReceiver object backed by JniProxy.
BroadcastWaiter
Waits for intents received by the managed BroadcastReceiver.
DynamicProxy
Java dynamic proxy with an invocation handler backed by the Rust closure.
Intent
A android.content.Intent reference, tied to a JNI local reference frame.
IntentFilter
A android.content.IntentFilter reference, tied to a JNI local reference frame.
JBoolean
A java.lang.Boolean reference, tied to a JNI local reference frame.
JByte
A java.lang.Byte reference, tied to a JNI local reference frame.
JCharacter
A java.lang.Character reference, tied to a JNI local reference frame.
JDouble
A java.lang.Double reference, tied to a JNI local reference frame.
JFloat
A java.lang.Float reference, tied to a JNI local reference frame.
JInteger
A java.lang.Integer reference, tied to a JNI local reference frame.
JLong
A java.lang.Long reference, tied to a JNI local reference frame.
JMethod
A java.lang.reflect.Method reference, tied to a JNI local reference frame.
JNumber
A java.lang.Number reference, tied to a JNI local reference frame.
JShort
A java.lang.Short reference, tied to a JNI local reference frame.
PermissionRequest
Android runtime permission request utility.

Traits§

DexClassLoader
Provides DEX class loading support for Android.

Functions§

android_api_level
Gets the API level (SDK version) of the current Android OS.
android_app_cache_dir
Returns the absolute path to the application specific cache directory.
android_app_files_dir
Returns the absolute path to the directory holding application files. No permissions are required for the calling app to read or write files under the returned path.
android_app_name
Gets the raw name of the current Android application, parsed from the package name.
android_app_package_name
Gets the package name of the current Android application.
android_context
Gets the current android.content.Context from ndk_context, usually a reference of android.app.Application or android.app.NativeActivity. Please check the completed issue https://github.com/rust-mobile/android-activity/issues/228 if you had expected a reference of an activity to be returned by this function.
block_with_timeout
Convenient blocker for asynchronous functions, based on futures_lite and futures_timer. Warning: Blocking in the android_main() thread will block the future’s completion if it depends on event processing in this thread (check your glue crate like android_activity).
jni_get_vm
Try to get the JavaVM from jni::JavaVM::singleton, otherwise it gets the JavaVM from the ndk_context crate.
jni_with_env
Calls jni_get_vm, attaches the current thread to the JVM and executes the closure; The thread may stay attached even if it has not been attached previously.