从JNI获取Java中使用的字符串

从JNI获取Java中使用的字符串,第1张

从JNI获取Java中使用的字符串

以下代码应允许您访问字段 enrollmentID 。使用JNI
String函数
来读取/ *** 作它们。

// Load the classjclass jclass_JCV = env->FindClass(env, "my.package.JC_VerificationCandidate");jfieldID fid_enrollmentID = env->GetFieldID(env, jclass_JCV, "enrollmentID" , "Ljava/lang/String;");// Access the first element in the jVerificationCandList array jobject jc_v = env->GetObjectArrayElement(env, jVerificationCandList, 0);// get reference to the string jstring jstr = (jstring) env->GetObjectField(env, jc_v, enrollmentID);// Convert jstring to native stringconst char *nativeString = env->GetStringUTFChars(env, jstr, 0);


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5135763.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-17
下一篇2022-11-18

发表评论

登录后才能评论

评论列表(0条)

    保存