Created
November 6, 2017 14:43
-
-
Save madhavanmalolan/2ad457b12cb24ca68eca51b6b19f00c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <android/log.h> | |
#include "com_example_Controller.h" | |
#include <stdlib.h> | |
#include <stdbool.h> | |
int main(int argc, char **argv); | |
JavaVM *sVm = NULL; | |
jint JNI_OnLoad( JavaVM* vm, void* reserved ) | |
{ | |
sVm = vm; | |
return JNI_VERSION_1_6; | |
} | |
JNIEXPORT void JNICALL Java_com_example_Controller_run(JNIEnv *env, jobject obj, jobjectArray args) | |
{ | |
int i = 0; | |
int argc = 0; | |
char **argv = NULL; | |
jstring *strr = NULL; | |
if (args != NULL) { | |
argc = (*env)->GetArrayLength(env, args); | |
argv = (char **) malloc(sizeof(char *) * argc); | |
strr = (jstring *) malloc(sizeof(jstring) * argc); | |
for(i=0;i<argc;i++) { strr[i] = (jstring)(*env)->GetObjectArrayElement(env, args, i); | |
argv[i] = (char *)(*env)->GetStringUTFChars(env, strr[i], 0); | |
} | |
} | |
main(argc, argv); | |
for(i=0;i<argc;i++) { (*env)->ReleaseStringUTFChars(env, strr[i], argv[i]); | |
} | |
free(argv); | |
free(strr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment