Hello everyone, Can anyone tell me how to call java methods from unity c#. I tried the following but its not working for me.
In Unity :
void OnGUI () {
string somestring;
AndroidJavaClass jc= new AndroidJavaClass("com.example.pluginsample.MainActivity");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("instance");
somestring = jo.Call<string>("Foo");
GUI.Label (new Rect (20, 20, 100, 20), somestring);
}
In Java Class:
public String Foo()
{
return "Hello";
}