Android utility functions
Struct attaching the JNI environment. Detaches the
constructor
{
ThreadAttacher thread;
SomeFunction( thread.GetEnv() );
// Automatically detaches
}
{
ThreadAttacher thread;
JNIEnv* env = thread.GetEnv();
if (!env)
return;
...
}
Detaches the jni environment
ok - true if there was no java exceptions. False if there was an exception.
Is the environment attached and valid?
isattached - true if the environment is valid
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;
}
Gets the JNI environment
env - the attached environment
Gets the app native activity
activity - the app native activity
Load a class
env -
class_name -
class - the activity class loader
Load a class
env -
activity -
class_name -
class - the activity class loader
Activity result callback function type. Monitors events from the main activity. Used with RegisterOnActivityResultListener() and UnregisterOnActivityResultListener()
env -
activity -
request_code -
result_code -
result -
Registers an activity result callback. Multiple listeners are allowed.
[type:dmAndroid::OnActivityResult] - listener
Unregisters an activity result callback
[type:dmAndroid::OnActivityResult] - listener
onCreate callback function type. Used with RegisterOnActivityCreateListener() and UnregisterOnActivityCreateListener()
env -
activity -
Registers an onCreate callback. Multiple listeners are allowed.
[type:dmAndroid::OnActivityCreate] - listener
Unregisters an onCreate callback
[type:dmAndroid::OnActivityCreate] - listener