How to start an Android activity from a Unity Application?

前端 未结 2 1774
天涯浪人
天涯浪人 2021-01-31 06:09

I know this seems to be a trivial question but I could not find any concrete answer anywhere on the internet. I saw this very similar question on stackoverflow: How to start Uni

2条回答
  •  醉话见心
    2021-01-31 06:37

    try this Change this Launch() method to static and pass Android java object ie. "jo" to it like below.

    AndroidJavaClass androidJC = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject jo= androidJC.GetStatic("currentActivity");
    AndroidJavaClass jc = new AndroidJavaClass("package_name.Ur_Actvity_Name");
    jc.CallStatic("Launch",jo);`
    

    and change Launch() method to :

    public static Launch(Activity activity)
    {
     Intent myIntent = new Intent();
     activity.startActivity(myIntent);
    }
    

    Hope it will help.

提交回复
热议问题