I use AndroidJavaClass and AndroidJavaObject.
But my device return error.
02-26 17:56:34.391: E/Unity(9169): ! getMethodID("initPlasma", "(Ljava/lang/String;)V") FAILED!
02-26 17:56:34.391: E/Unity(9169): JNI: Unable to find method id for 'initPlasma'
//used Unity 4.x code
try
{
using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))
{
jo.Call(JavaMethods.initPlasma, "unity to android");
}
}
}
catch (Exception e)
{
Debug.Log(e.StackTrace);
}
export Eclipse project used Unity 4.x.
and I fixed extends UnityPlayerActivity.
ex) class mainActivity extends UnityPlayerActivity
and Added code.
public void initPlasma(final String unityMessage)
{
runOnUiThread(new Runnable() {
public void run()
{
UnityPlayer.UnitySendMessage("targetUnityObj", "OnInitCompleate", unityMessage + " and android to unity");
}
});
}
How can I edit it?