Question by
hirenkacha · Jul 15, 2020 at 11:43 AM ·
androidpluginthreading
Application.Quit() next to Android app switch code.
I want my game to quit and switch to another android app whenever SwitchApp() is called. I have code working. But problem is, while switching to an app, screen goes blank for 15-30 seconds and then switches to specified app. I tried different thread for switching the app. But did not work. Can any one help how to make this transition smooth?
private void SwitchApp()
{
Application.Quit();
LaunchApp.Instance.GoToApp();
}
======LaunchApp.cs=======
public void GoToApp()
{
bool fail = false;
string bundleId = "com.company.app";
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
AndroidJavaObject launchIntent = null;
try
{
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", bundleId);
}
catch (System.Exception e)
{
fail = true;
}
if (fail)
{
Application.OpenURL("https://companysite.com/");
}
else
ca.Call("startActivity", launchIntent);
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
}
Comment
Your answer
Follow this Question
Related Questions
How to make work an android plugin on another thread?? 0 Answers
Using BackgroundWorker with Unity, Completed not running on Main thread ? 1 Answer
unity socket bug or Threadpool bug ? please help,, 0 Answers
Is build.gradle take in account when building? 0 Answers
Android plug-in - how to convert AndroidJavaObject to String[]? 0 Answers