Struct NativeActivity

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

An ANativeActivity *

This is either provided in ANativeActivity_onCreate, or accessible in android_native_app_glue’s android_app.

Implementations§

Source§

impl NativeActivity

Source

pub unsafe fn from_ptr(ptr: NonNull<ANativeActivity>) -> Self

Create a NativeActivity from a pointer

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

Source

pub fn ptr(&self) -> NonNull<ANativeActivity>

The pointer to the native ANativeActivity

Source§

impl NativeActivity

Methods that relate to fields of the struct itself

The relevant NDK docs can be found here.

Source

pub fn sdk_version(&self) -> i32

The platform’s SDK version code

Source

pub fn internal_data_path(&self) -> &CStr

Path to this application’s internal data directory

Source

pub fn external_data_path(&self) -> &CStr

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

Source

pub fn asset_manager(&self) -> AssetManager

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

Source

pub fn instance(&self) -> *mut c_void

Instance data associated with the activity

Source

pub unsafe fn set_instance(&mut self, data: *mut c_void)

Set the instance data associated with the activity

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

Source

pub fn vm(&self) -> JavaVM

This process’s JavaVM object.

let vm = native_activity.vm();
let env = vm.attach_current_thread();
// Do JNI with env ...
Source

pub fn activity(&self) -> JObject<'_>

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.

Source

pub unsafe fn obb_path(&self) -> &CStr

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

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

Source§

impl NativeActivity

Methods that relate to ANativeActivity_* functions.

The relevant NDK docs can be found here.

Source

pub fn finish(&self)

Sends a destroy event to the activity and stops it.

Source

pub fn show_soft_input(&self, force: bool)

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.

Source

pub fn hide_soft_input(&self, not_always: bool)

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.

Trait Implementations§

Source§

impl Debug for NativeActivity

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for NativeActivity

Source§

impl Sync for NativeActivity

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<'a, T> Desc<'a, T> for T

Source§

fn lookup(self, _: &JNIEnv<'a>) -> Result<T, Error>

Look up the concrete type from the JVM.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.