- Home /
Unable to call method via AndroidJNI.CallStaticVoidMethod
Hello,
I'm struggling to call a method in a Java class embedded as part of an library to the project. The code is in Javascript:
var classID = AndroidJNI.FindClass("com.mycompany.myprog.Myclass");
var methodID = AndroidJNI.GetStaticMethodID(classID, "jniTest", "(Ljava/lang/Object;)V");
var params : jvalue[];
AndroidJNI.CallStaticVoidMethod(classID, methodID, params);
The classID is a valid int pointer as well as the methodID, the CallStaticVoidMethod does not work though and crashes the app. The problem seems to be the params parameter. The documentation says it should be an array of jvalue. How can I assign values to it? I was able to declare this array as seen above, so the script compiles. The documentation also says that the parameter is optional. But in Javascript at least I'm getting a compile time error when omitting it. Actually I don't even want to submit a parameter so a call like
AndroidJNI.CallStaticVoidMethod(classID, methodID)
would be good enough for me but Unity won't let me do this even though the examples in the documentation state it should work.
Thanks Ben
Your answer

Follow this Question
Related Questions
AndroidJNI reports lots of exceptions that don't propagate to Unity 0 Answers
Is it possible to cast AndroidJavaObject to its java subclass in C#? 1 Answer
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Calling .jar function in unity 3 Answers