1al_android_get_jni_env(3) al_android_get_jni_env(3)
2
3
4
6 al_android_get_jni_env - Allegro 5 API
7
9 #include <allegro5/allegro_android.h>
10
11 JNIEnv *al_android_get_jni_env(void)
12
14 Returns the Android JNI environment used by Allegro to call into Java.
15 As a convenience this function provides it to the user so there is no
16 need to obtain it yourself.
17
18 For example if you have a Java method “void send(String message)” in
19 your activity class, you could call it like this from C code:
20
21 JNIEnv * env = al_android_get_jni_env();
22 jclass class_id = (* env)->GetObjectClass(env, al_android_get_activity());
23 jmethodID method_id = (* env)->GetMethodID(env, class_id, "send",
24 "(Ljava/lang/String;)V");
25 jstring jdata = (* env)->NewStringUTF(env, "Hello Java!");
26 (* env)->CallVoidMethod(env, al_android_get_activity(), method_id, jdata);
27 (* env)->DeleteLocalRef(env, jdata);
28
30 5.2.2
31
32 [Unstable API]: This API is new and subject to refinement.
33
34
35
36Allegro reference manual al_android_get_jni_env(3)