src/main/android/SDL_android_main.c
changeset 7501 b27825bb5879
parent 7467 998579383ced
child 7663 53fe1b64eb2d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/android/SDL_android_main.c	Mon Jul 22 02:51:45 2013 -0700
@@ -0,0 +1,38 @@
+
+#include "SDL_config.h"
+
+#ifdef __ANDROID__
+
+/* Include the SDL main definition header */
+#include "SDL_main.h"
+
+/*******************************************************************************
+                 Functions called by JNI
+*******************************************************************************/
+#include <jni.h>
+
+// Called before SDL_main() to initialize JNI bindings in SDL library
+extern void SDL_Android_Init(JNIEnv* env, jclass cls);
+
+// Start up the SDL app
+void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
+{
+    /* This interface could expand with ABI negotiation, calbacks, etc. */
+    SDL_Android_Init(env, cls);
+
+    SDL_SetMainReady();
+
+    /* Run the application code! */
+    int status;
+    char *argv[2];
+    argv[0] = SDL_strdup("SDL_app");
+    argv[1] = NULL;
+    status = SDL_main(1, argv);
+
+    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
+    //exit(status);
+}
+
+#endif /* __ANDROID__ */
+
+/* vi: set ts=4 sw=4 expandtab: */