pub struct NativeActivity { /* private fields */ }
Expand description

A native ANativeActivity *

This is either provided in ffi::ANativeActivity_onCreate(), or accessible through ndk_glue::native_activity().

Implementations

Create a NativeActivity from a pointer

Safety

By calling this function, you assert that it is a valid pointer to a native ANativeActivity.

The pointer to the native ANativeActivity

Methods that relate to fields of the struct itself

The relevant NDK docs can be found here.

The platform’s SDK version code

Path to this application’s internal data directory

Path to this application’s external (removable, mountable) data directory

This app’s asset manager, which can be used to access assets from the .apk file.

Instance data associated with the activity

Set the instance data associated with the activity

Safety

This can invalidate assumptions held by ndk-glue, as well as cause data races with concurrent access to the instance data.

This process’s JavaVM object.

Usage with jni crate:

let vm_ptr = native_activity.vm();
let vm = unsafe { jni::JavaVM::from_raw(vm_ptr) }.unwrap();
let env = vm.attach_current_thread();
// Do JNI with env ...

Usage with jni-glue crate:

let vm_ptr = native_activity.vm();
let vm = unsafe { jni_glue::VM::from_jni_local(&*vm_ptr) };
vm.with_env(|env| {
    // Do JNI with env ...
});

The android.app.NativeActivity instance

In the JNI, this is named clazz; however, as the docs say, “it should really be named ‘activity’ instead of ‘clazz’, since it’s a reference to the NativeActivity instance”.

Path to the directory with the application’s OBB files.

Safety

Only available as of Honeycomb (Android 3.0+, API level 11+)

Methods that relate to ANativeActivity_* functions.

The relevant NDK docs can be found here.

Sends a destroy event to the activity and stops it.

Shows the IME (the on-screen keyboard).

If force is true, the SHOW_FORCED flag is used; otherwise, the SHOW_IMPLICIT flag is used. Depending on the value of this flag, the hide_soft_input method with behave differently. See the relevant javadoc for more information.

Hides the IME (the on-screen keyboard).

If not_always is true, the HIDE_NOT_ALWAYS flag is used; otherwise, the HIDE_IMPLICIT_ONLY flag is used. Depending on the value of this flag and the way the IME was shown, it may or may not be hidden. See the relevant javadoc for more information.

Change the window format of the given activity.

Calls getWindow().setFormat() of the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.

Change the window flags of the given activity.

Calls getWindow().setFlags() of the given activity.

Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.