2 SDL_android_main.c, placed in the public domain by Sam Lantinga 3/13/14
4 #include "../../SDL_internal.h"
8 /* Include the SDL main definition header */
11 /*******************************************************************************
12 Functions called by JNI
13 *******************************************************************************/
16 /* Called before SDL_main() to initialize JNI bindings in SDL library */
17 extern void SDL_Android_Init(JNIEnv* env, jclass cls);
19 /* Start up the SDL app */
20 JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
26 /* This interface could expand with ABI negotiation, callbacks, etc. */
27 SDL_Android_Init(env, cls);
31 /* Prepare the arguments. */
33 int len = (*env)->GetArrayLength(env, array);
34 char* argv[1 + len + 1];
36 /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
37 https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
39 argv[argc++] = SDL_strdup("app_process");
40 for (i = 0; i < len; ++i) {
43 jstring string = (*env)->GetObjectArrayElement(env, array, i);
45 utf = (*env)->GetStringUTFChars(env, string, 0);
47 arg = SDL_strdup(utf);
48 (*env)->ReleaseStringUTFChars(env, string, utf);
50 (*env)->DeleteLocalRef(env, string);
60 /* Run the application. */
62 status = SDL_main(argc, argv);
64 /* Release the arguments. */
66 for (i = 0; i < argc; ++i) {
70 /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
76 #endif /* __ANDROID__ */
78 /* vi: set ts=4 sw=4 expandtab: */