Created
December 26, 2016 03:37
-
-
Save arumoy/05e7302b2e480e55d9170540e9c33085 to your computer and use it in GitHub Desktop.
Open Other App From Unity C# Script - Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how about open url that in embedded in image to click and go to the webpage