project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp
branchhedgeroid
changeset 5353 37b0fb82e22c
parent 5335 cd9b7b170fbf
child 5389 b3cc5b4099f1
equal deleted inserted replaced
5350:4c100fbfad5f 5353:37b0fb82e22c
    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);