我正在使用android java插件进行统一我试图从java统一调用函数并且它成功运行。
cls_Activity = AndroidJNI.FindClass("com/unity3d/player/UnityPlayer");
fid_Activity = AndroidJNI.GetStaticFieldID(cls_Activity, "currentActivity", "Landroid/app/Activity;");
obj_Activity = AndroidJNI.GetStaticObjectField(cls_Activity, fid_Activity);
kdataActivityClass = AndroidJNI.FindClass("com/kdata/unitytest/UnityUrlPlugin");
startAdsMethod = AndroidJNI.GetMethodID(kdataActivityClass,"getURL","(I)Ljava/lang/String;");
jvalue[] myArray = new jvalue[1];
myArray[0].i =testvalue;
gui.text= AndroidJNI.CallStaticStringMethod(obj_Activity, startAdsMethod, myArray);
使用上面的代码,我可以将int
value 传递给我的 java 函数并接收string
value 。当我试图传递一个字符串值时,它对我不起作用。问题出在此处,因为 JNI 中没有字符串类型
jvalue[] myArray = new jvalue[1];
myArray[0].i =testvalue;