Namespace: dmAndroid
Language: C++
Type: Defold C++
File: android.h
Source: engine/dlib/src/dmsdk/dlib/android.h
Include: dmsdk/dlib/android.h
Android utility functions
Type: FUNCTION Detaches the jni environment
Returns
ok (bool) - true if there was no java exceptions. False if there was an exception.Type: FUNCTION Gets the app native activity
Returns
activity (ANativeActivity*) - the app native activityType: FUNCTION Gets the JNI environment
Returns
env (JNIENV*) - the attached environmentType: FUNCTION Is the environment attached and valid?
Returns
isattached (bool) - true if the environment is validExamples
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;
}
Type: FUNCTION Load a class
Parameters
env (JNIEnv*)class_name (const char*)Returns
class (jclass) - the activity class loaderType: FUNCTION Load a class
Parameters
env (JNIEnv*)activity (jobject)class_name (const char*)Returns
class (jclass) - the activity class loaderType: TYPEDEF onCreate callback function type. Used with RegisterOnActivityCreateListener() and UnregisterOnActivityCreateListener()
Parameters
env (JNIEnv*)activity (jobject)Type: TYPEDEF Activity result callback function type. Monitors events from the main activity. Used with RegisterOnActivityResultListener() and UnregisterOnActivityResultListener()
Parameters
env (JNIEnv*)activity (jobject)request_code (int32_t)result_code (int32_t)result (void*)Type: FUNCTION Registers an onCreate callback. Multiple listeners are allowed.
Notes
Parameters
listener (dmAndroid::OnActivityCreate)Type: FUNCTION Registers an activity result callback. Multiple listeners are allowed.
Notes
Parameters
listener (dmAndroid::OnActivityResult)Type: CLASS Struct attaching the JNI environment.
Type: FUNCTION constructor
Examples
{
ThreadAttacher thread;
SomeFunction( thread.GetEnv() );
// Automatically detaches
}
{
ThreadAttacher thread;
JNIEnv* env = thread.GetEnv();
if (!env)
return;
...
}
Type: FUNCTION Unregisters an onCreate callback
Notes
Parameters
listener (dmAndroid::OnActivityCreate)Type: FUNCTION Unregisters an activity result callback
Notes
Parameters
listener (dmAndroid::OnActivityResult)