al_android_get_jni_env man page

al_android_get_jni_env — Allegro 5 API

Synopsis

#include <allegro5/allegro_android.h>

JNIEnv *al_android_get_jni_env(void)

Description

Returns the Android JNI environment used by Allegro to call into Java. As a convenience this function provides it to the user so there is no need to obtain it yourself.

For example if you have a Java method "void send(String message)" in your activity class, you could call it like this from C code:

JNIEnv * env = al_android_get_jni_env();
jclass class_id = (* env)->GetObjectClass(env, al_android_get_activity());
jmethodID method_id = (* env)->GetMethodID(env, class_id, "send",
    "(Ljava/lang/String;)V");
jstring jdata = (* env)->NewStringUTF(env, "Hello Java!");
(* env)->CallVoidMethod(env, al_android_get_activity(), method_id, jdata);
(* env)->DeleteLocalRef(env, jdata);

Since

5.2.2

[Unstable API]: This API is new and subject to refinement.

Info

Allegro reference manual