对不起,我写错了我的代码是正确的,但我不知道为什么我不能正确String = "str"
?
Log.d(TAG, "" +ndk.callStructure());
JNIEXPORT jstring JNICALL
Java_com_example_demo_Ndk_callStructure(JNIEnv *env, jobject instance) {
jclass cls;
jmethodID mid;
cls= (*env)->FindClass(env,"java/lang/String");
mid =(*env)->GetMethodID(env,cls,"<init>","([C)V");
jcharArray arr = (*env)->NewCharArray(env,3);
(*env)->SetCharArrayRegion(env,arr,0,3,"str");
jstring str=(*env)->NewObject(env,cls,mid,arr);
(*env)->DeleteLocalRef(env,arr);
(*env)->DeleteLocalRef(env,cls);
return str;
}