I am working on unity with android javas plugin. I tried to call a function from java in unity, and it worked successfully.
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);
Using the code above, I was included to pass the int
value to my java function and got the string
value. When I try to pass a string value, it does not work for me. The problem here is because there is no string type in JNI
jvalue[] myArray = new jvalue[1]; myArray[0].i =testvalue;
source share