sdlGetAndroidActivity function

Pointer<NativeType> sdlGetAndroidActivity()

Retrieve the Java instance of the Android activity class.

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

The jobject returned by the function is a local reference and must be released by the caller. See the PushLocalFrame() and PopLocalFrame() or DeleteLocalRef() functions of the Java native interface:

https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html

\returns the jobject representing the instance of the Activity class of the Android application, 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_GetAndroidJNIEnv

extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void)

Implementation

Pointer<NativeType> sdlGetAndroidActivity() {
  final sdlGetAndroidActivityLookupFunction = libSdl3.lookupFunction<
      Pointer<NativeType> Function(),
      Pointer<NativeType> Function()>('SDL_GetAndroidActivity');
  return sdlGetAndroidActivityLookupFunction();
}