AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic("currentActivity");
activity.CallStatic("testMethod");
This is how I call Android static function without argument, and its works perfect. But I have issue when I'm trying to call non-static function with arguments.
I'm trying to call it like that:
activity.Call("testMethod", "testString");
But Android throws exception:
AndroidJavaException: java.lang.NoSuchMethodError: no non-static method "L**myActivity**(Ljava/lang/String;)V"
What I do wrong ? What is the difference between static and non-static call ? I'm using the same activity. Here is my java method:
public void testMethod(String data) { }
UPDATE
Finally was able to run non static method:
activity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
{
activity.Call("testMethod", "testString");
}));
That odd thats not working without runOnUIThread...Probably I did something wrong.