- Home /
Launching Android Apps from Unity
Hi Guys,
I have a strange question. Does anyone know if you can launch other apps from within your App? Here's the situation. My client wants to host Android games in my App as UI shortcut buttons that when pressed will launch the corresponding android game or App.
Any ideas?
Thanks.
Answer by xxmariofer · Nov 18, 2020 at 06:19 PM
is not a strange question and has been answer before https://forum.unity.com/threads/android-ios-launch-from-within-a-unity-app-another-unity-app.222709/?_ga=2.89812563.95253068.1605723327-1322877492.1590351887#post-2308076
If youre not bothered to scroll to find the answer, this is what that thread has answered. Credits go to the writer and xxmariofer for posting the link.
bool fail = false;
string bundleId = com.google.appname; // your target bundle id
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject package$$anonymous$$anager = ca.Call<AndroidJavaObject>("getPackage$$anonymous$$anager");
AndroidJavaObject launchIntent = null;
try
{
launchIntent = package$$anonymous$$anager.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();
package$$anonymous$$anager.Dispose();
launchIntent.Dispose();
Thanks for the answer. I'm sorry I was not able to find this on my own on the forum. I tried different variations of the question and did not see the post you referenced. Thanks again for the help.
Your answer
![](https://koobas.hobune.stream/wayback/20220613020041im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Poll which line of code app is stuck at? 1 Answer
creating a game? 3 Answers
Programatically creating entire Unity games 2 Answers
Apps crash in development build 0 Answers
Can i create a virtual globe in unity? 0 Answers