22 /* This interface could expand with ABI negotiation, calbacks, etc. */ |
22 /* This interface could expand with ABI negotiation, calbacks, etc. */ |
23 SDL_Android_Init(env, cls); |
23 SDL_Android_Init(env, cls); |
24 |
24 |
25 //Get the String array from java |
25 //Get the String array from java |
26 int argc = env->GetArrayLength(strArray); |
26 int argc = env->GetArrayLength(strArray); |
27 char* argv[argc]; |
27 char *argv[argc]; |
28 jstring jstringArgv[argc]; |
28 jstring jstringArgv[argc]; |
29 for(int i = 0; i < argc; i++){ |
29 for(int i = 0; i < argc; i++){ |
30 jstringArgv[i] = (jstring)env->GetObjectArrayElement(strArray, i); //get the element |
30 jstringArgv[i] = (jstring)env->GetObjectArrayElement(strArray, i); //get the element |
|
31 argv[i] = (char*)malloc(sizeof(char) * env->GetStringLength(jstringArgv[i])); |
31 strcpy(argv[i], env->GetStringUTFChars(jstringArgv[i], JNI_FALSE)); //copy it to a mutable location |
32 strcpy(argv[i], env->GetStringUTFChars(jstringArgv[i], JNI_FALSE)); //copy it to a mutable location |
32 env->ReleaseStringChars(jstringArgv[i], (jchar*)argv[i]); //release mem |
33 //Don't release memory the JAVA GC will take care of it |
|
34 //env->ReleaseStringChars(jstringArgv[i], (jchar*)argv[i]); |
33 } |
35 } |
34 |
36 |
35 /* Run the application code! */ |
37 /* Run the application code! */ |
36 int status; |
38 int status; |
37 status = SDL_main(argc, argv); |
39 status = SDL_main(argc, argv); |