2017-01-23 57 views

回答

0

試一下這個寫的kingandroid at unity forums

 bool fail = false; 
     string bundleId = com.google.appname; // your target bundle id 
     AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 
     AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity"); 
     AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager"); 

     AndroidJavaObject launchIntent = null; 
     try 
     { 
      launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId); 
     } 
     catch (System.Exception e) 
     { 
      fail = true; 
     } 

     if (fail) 
     { //open app in store 
      Application.OpenURL("https://google.com"); 
     } 
     else //open the app 
      ca.Call("startActivity",launchIntent); 

     up.Dispose(); 
     ca.Dispose(); 
     packageManager.Dispose(); 
     launchIntent.Dispose(); 

此代碼是從團結的應用程序中打開一個統一的應用程序。我不是Android(或android studio)的專家,所以我不確定它是否可以與這些應用程序一起工作。

希望它有幫助!

相關問題