Android

Convert char* to jstring in JNI

aucd29 2015. 3. 24. 09:58

You could just check JNI api documentation. E.g. Here.
You will find:

jstring NewStringUTF(JNIEnv *env, const char *bytes);

So all you have to do it something like this:

char *buf = (char*)malloc(10);
strcpy(buf, "1234567890");
jstring jstrBuf = (*env)->NewStringUTF(env, buf);


http://stackoverflow.com/questions/16939349/convert-char-to-jstring-in-jni-when-char-is-passed-using-va-arg