Is there any way to pause an android app? Like Application.Quit, but without a full exit

This functionality would help me with an unrelated issue (slowdowns on oculus go when accessing the home menu and returning). Since there’s an Application.Quit() method, and since mobile has different “flavors” of being closed, I was wondering if there’s any way to induce that behavior programatically. I see many apps which have a “press back to exit” function, that doesn’t actually exit - it still appears in my “recent apps” list - keeping the program in memory to be restored instantly.

Has anyone managed to do this in a Unity project? Thanks!

AFAIK there isn’t existing Unity function for that, but you can use intent to move to home screen
https://stackoverflow.com/questions/2752319/android-simulate-home-click

Thanks so much for this! I was able to get it working great with that link. For anyone who may stumble on this thread, the code ended up being something like:

    public static void GotoAndroidHome()
    {
        AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", "android.intent.action.MAIN");
        intent.Call<AndroidJavaObject>("addCategory", "android.intent.category.HOME");
        var activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        var activity = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
        activity.Call("startActivity", intent);
    }
1 Like