Forum Discussion
Weitin
6 years agoProtege
How to force close an app on Android?
I'm trying to use an app to launch another app using the following code.
I can launch games from the launcher correctly, however I noticed the launcher app will still have a running instance (when returning from games and loading through Oculus home menu). The Oculus Quest basically only allows you to run one app at a time, which confuses me. Using the same code, I can load the launcher where I left off with no problems. But once I've launched a game, return to the launcher, then try to launch the same game, it says "AppName has stopped". I think the related error I get is: 'Consumer closed input channel or an error occurred. events=0x9'
I think a solution is to force close an app when I load the new app. How can I properly do this? Application.Quit()?
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
ca.Call("startActivity", launchIntent);I'll call this app the launcher and the other apps are games.I can launch games from the launcher correctly, however I noticed the launcher app will still have a running instance (when returning from games and loading through Oculus home menu). The Oculus Quest basically only allows you to run one app at a time, which confuses me. Using the same code, I can load the launcher where I left off with no problems. But once I've launched a game, return to the launcher, then try to launch the same game, it says "AppName has stopped". I think the related error I get is: 'Consumer closed input channel or an error occurred. events=0x9'
I think a solution is to force close an app when I load the new app. How can I properly do this? Application.Quit()?
1 Reply
Replies have been turned off for this discussion
- WeitinProtegeSo it turns out Application.Quit() is the reason my games are crashing when I load them after the first time. Application.Quit() on Android seems to exit the app, but doesn't fully remove the app which is causing the crashing behaviour. Use this instead:
System.Diagnostics.Process.GetCurrentProcess().Kill();
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 months ago
- 10 months ago
- 2 years ago