i have calling java function from my unity code. I have both static & non-static type of functions in my java class To access first static function, i u
use your "activity" variable for non-static calls: activity.Call("Enable", qwe);
There is example of static and non-static functions calls:
public class Caller {
private readonly AndroidJavaClass _ActivityClass;
private readonly AndroidJavaObject _ActivityObject;
private readonly AndroidJavaClass _MyActivityClass;
public Caller() {
_ActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
_MyActivityClass = new AndroidJavaClass("com.example.u2aTest.MyMainActivity");
_ActivityObject = _ActivityClass.GetStatic("currentActivity");
// AndroidJavaObject my_activity_object = _MyActivityClass.GetStatic("currentActivity"); //doesn't work
}
public void MakeTestCalls() {
_ActivityObject.Call("testVoid"); // works fine
//_ActivityClass.CallStatic("testVoidStatic"); // doesn't works
_MyActivityClass.CallStatic("testVoidStatic"); // works fine
//_ActivityObject.CallStatic("testVoid"); // doesn't work on some divices
//public int testInt(int intValue)
int iresult = _ActivityObject.Call<int>("testInt", 999);
//public String testStringString(String paramValue)
String sresult = _ActivityObject.Call<String>("testStringString", "s2");
//public static int testIntStatic(int intValue)
iresult = _MyActivityClass.CallStatic<int>("testIntStatic", 999);
//public static String testStringStringStatic(String paramValue)
sresult =_MyActivityClass.CallStatic<String>("testStringStringStatic", "s1");
}
}
Take a look on example of Android plugin for Unity3D for detailes.