Skip to content

Instantly share code, notes, and snippets.

@arumoy
Created December 26, 2016 03:37
Show Gist options
  • Save arumoy/05e7302b2e480e55d9170540e9c33085 to your computer and use it in GitHub Desktop.
Save arumoy/05e7302b2e480e55d9170540e9c33085 to your computer and use it in GitHub Desktop.
Open Other App From Unity C# Script - Android
public void OpenApp() {
string bundleId = "<App Package Name>"; // your target bundle id
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
//if the app is installed, no errors. Else, doesn't get past next line
AndroidJavaObject launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
ca.Call("startActivity",launchIntent);
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
}
Copy link

ghost commented Dec 8, 2023

how about open url that in embedded in image to click and go to the webpage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment