al_android_get_jni_env(3alleg5)

al_android_get_jni_env3alleg5

Allegro 5 api

Usage

#include <allegro5/allegro_android.h>
JNIEnv *al_android_get_jni_env(void)

Overview

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.

Releases

5 releases since Debian 9 (Stretch); the text changed 4 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13

From allegro5-doc 2:5.2.10.1+dfsg-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.