pub unsafe fn init(vm: *mut c_void, context: *mut c_void) -> Result<(), Error>Expand description
Hands the crate the process’s JavaVM and a Context, from which it keeps the
application Context for the life of the process.
Once init has succeeded, the crate uses what it was given and ignores ndk-context.
A second call with the same JavaVM returns Ok and changes nothing, so a host whose
set-up code runs more than once needs no guard of its own.
§Errors
Error::Io when the thread cannot attach to vm, when context has no application
yet (getApplicationContext() is null), or when an earlier call succeeded with a
different JavaVM.
§Safety
vm is a valid JavaVM*, and context is a valid JNI reference (local or global) to
an android.content.Context (an Activity, a Service or the Application) alive for
the duration of the call. The crate only borrows context; the caller keeps ownership.