Android

Android utility functions

ThreadAttacher()

Struct attaching the JNI environment. Detaches the

Struct attaching the JNI environment. Detaches the


ThreadAttacher()

constructor

constructor

EXAMPLES

{
  ThreadAttacher thread;
  SomeFunction( thread.GetEnv() );
  // Automatically detaches
}
{
  ThreadAttacher thread;
  JNIEnv* env = thread.GetEnv();
  if (!env)
    return;
  ...
}


Detach()

Detaches the jni environment

Detaches the jni environment

RETURN

ok - true if there was no java exceptions. False if there was an exception.


IsAttached()

Is the environment attached and valid?

Is the environment attached and valid?

RETURN

isattached - true if the environment is valid

EXAMPLES

Result SomeFunc() {
  ThreadAttacher thread;
  JNIEnv* env = thread.GetEnv();
  if (!env)
    return RESULT_ATTACH_FAILED;
  ... calls using jni
  return thread.Detach() ? RESULT_OK : RESULT_JNI_CALLS_FAILED;
}


GetEnv()

Gets the JNI environment

Gets the JNI environment

RETURN

env - the attached environment


GetActivity()

Gets the app native activity

Gets the app native activity

RETURN

activity - the app native activity


LoadClass(env, class_name)

Load a class

Load a class

PARAMETERS

env -

class_name -

RETURN

class - the activity class loader


LoadClass(env, activity, class_name)

Load a class

Load a class

PARAMETERS

env -

activity -

class_name -

RETURN

class - the activity class loader


OnActivityResult

OnActivityResult callback typedef

Activity result callback function type. Monitors events from the main activity. Used with RegisterOnActivityResultListener() and UnregisterOnActivityResultListener()

PARAMETERS

env -

activity -

request_code -

result_code -

result -


RegisterOnActivityResultListener([type:dmAndroid::OnActivityResult])

register Android activity result callback

Registers an activity result callback. Multiple listeners are allowed.

PARAMETERS

[type:dmAndroid::OnActivityResult] - listener


UnregisterOnActivityResultListener([type:dmAndroid::OnActivityResult])

unregister Android activity result callback

Unregisters an activity result callback

PARAMETERS

[type:dmAndroid::OnActivityResult] - listener


OnActivityCreate

OnActivityCreate callback typedef

onCreate callback function type. Used with RegisterOnActivityCreateListener() and UnregisterOnActivityCreateListener()

PARAMETERS

env -

activity -


RegisterOnActivityCreateListener([type:dmAndroid::OnActivityCreate])

register Android onCreate callback

Registers an onCreate callback. Multiple listeners are allowed.

PARAMETERS

[type:dmAndroid::OnActivityCreate] - listener


UnregisterOnActivityCreateListener([type:dmAndroid::OnActivityCreate])

unregister Android onCreate callback

Unregisters an onCreate callback

PARAMETERS

[type:dmAndroid::OnActivityCreate] - listener