Quantcast
Channel: Answers by "Vandarthul"
Viewing all articles
Browse latest Browse all 86

Answer by Vandarthul

$
0
0
Hey @ishafdo4 Try this: public void LaunchApp(string package, string storeLink = null) { bool fail = false; string bundleId = package; // your target bundle id AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ca = up.GetStatic("currentActivity"); AndroidJavaObject packageManager = ca.Call("getPackageManager"); AndroidJavaObject launchIntent = null; try { launchIntent = packageManager.Call("getLaunchIntentForPackage", bundleId); } catch (System.Exception e) { fail = true; } if (fail && storeLink != null) { //open app in store Application.OpenURL(storeLink); } else //open the app ca.Call("startActivity", launchIntent); up.Dispose(); ca.Dispose(); packageManager.Dispose(); launchIntent.Dispose(); } package is bundleIdentifier of app, such as "com.facebook.katana" and optional parameter is the store link of the app in case the app is not found in device, you can leave it as null and it will only try to open the app if it exists.

Viewing all articles
Browse latest Browse all 86

Trending Articles