void Start()//在android测试成功
{
bool fail = false;
string bundleId = "跳转的包名";//包名称
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic
AndroidJavaObject packageManager = ca.Call
AndroidJavaObject launchIntent = null;
try
{
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", bundleId);
Debug.Log("没Try到");
}
catch (System.Exception e)
{
fail = true; // 应用未安装
Debug.LogError(e);
}
if (fail)
{
//跳转应用下载地址 测试过两次这里没用
Application.OpenURL("网站下载链接");
Debug.Log("跳转");
}
else
{
try
{
ca.Call("startActivity", launchIntent);
}
catch (System.Exception e)
{
Application.OpenURL("网站下载链接");//会跳转
Debug.Log("捕获异常");
throw e;
}
}
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
}