- Home /
Using AndroidJavaObject.CallStatic to retrieve a return value
Hi all,
I'm having some issues getting AndroidJavaObject's CallStatic to work for any primitive type, when a return value is expected. I am able to call void methods without issue.
In C#, I'm declaring the object as such:
public AndroidJavaClass myJavaClass = new AndroidJavaClass("com.myapp.....");
Here's where it gets weird. Given two Java methods in that class:
public static void methodA(final String parameter)
{
...
}
public static boolean methodB(final String parameter)
{
....
return true;
}
The latter is not working when called from C#.
There is no problem with the void method, which executes its Android native code as intended, when called as such:
myJavaClass.CallStatic("methodA", "hello world");
However, I am getting JNI exceptions when I call:
bool myBool = myJavaClass.CallStatic<bool>("methodB", "some paramter");
I am not sure what is wrong with #2 here, but Unity definitely doesn't like it:
I/Unity ( 7121): ExecutionEngineException: JNI Exception
I/Unity ( 7121): at UnityEngine.AndroidJavaObject._CallStatic[Boolean] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
I/Unity ( 7121): at UnityEngine.AndroidJavaObject.CallStatic[Boolean] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
Your answer
Follow this Question
Related Questions
Getting byte[] or ByteBuffer[] from native Java 1 Answer
Now that Unity 4.1.2 broke the Android plugin examples, what do you use to learn them? 1 Answer
using shared libraries generated by Android project in Unity 0 Answers
Android plugin dependency 1 Answer
Using the MPFR number library on Android 0 Answers