My Unity code:
// to get the activity
AndroidJavaClass androidJC = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = androidJC.GetStatic<AndroidJavaObject>("currentActivity");
// Accessing the class to call a static method on it
AndroidJavaClass jc = new AndroidJavaClass("com.lf.clientsampleapp.MainActivity");
// Calling a Call method to which the current activity is passed
jc.CallStatic("Call", jo);
My plugins Java code:
public class MainActivity extends UnityPlayerActivity
{
public static void Call(Activity activity)
{
// Creating an intent with the current activity and the activity we wish to start
Intent myIntent = new Intent(activity, MainActivity.class);
activity.startActivity(myIntent);
}
public static void Call()
{
//Calling this method without a parameter works fine...
}
This produces a NoSuchMethod exception. But if I call the same method without a parameter from Unity using
jc.CallStatic("Call")
it works fine. So, there is some mapping issue with the parameter.
I tried other variants, like
jc.CallStatic("Call", new object[] { jo });
But still no go… How do I do this?