我是 unity 的新手,想连接市场上的应用程序页面或任何其他应用程序,所以我在其他线程中使用了一些脚本,但它没有用,所以我认为它也需要在 Android 清单中进行一些更改才能使脚本工作. 我的脚本是这样的,游戏中的一个按钮运行它的功能。
bool fail = false;
string bundleId = "bazaar://details?id=" + "cab.snapp.passenger"; // 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();
我更改了字符串包,但它没有用,如果有任何方法可以使用 intent 和 Uri 在 unity c# 中打开另一个应用程序,那么除了这个问题的解决方案之外,我还很期待。