sdlGetAndroidJniEnv function

Pointer<NativeType> sdlGetAndroidJniEnv()

Get the Android Java Native Interface Environment of the current thread.

This is the JNIEnv one needs to access the Java virtual machine from native code, and is needed for many Android APIs to be usable from C.

The prototype of the function in SDL's code actually declare a void* return type, even if the implementation returns a pointer to a JNIEnv. The rationale being that the SDL headers can avoid including jni.h.

\returns a pointer to Java native interface object (JNIEnv) to which the current thread is attached, or NULL on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.1.3.

\sa SDL_GetAndroidActivity

extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidJNIEnv(void)

Implementation

Pointer<NativeType> sdlGetAndroidJniEnv() {
  final sdlGetAndroidJniEnvLookupFunction = libSdl3.lookupFunction<
      Pointer<NativeType> Function(),
      Pointer<NativeType> Function()>('SDL_GetAndroidJNIEnv');
  return sdlGetAndroidJniEnvLookupFunction();
}