When I install the game on my device the quit functionality is not working. I have a main menu and a Quit button with onclick event. I added Debug.Log to that onclick function and it prints, so the function is being called but the application does not exit.
I’ve tried:
#if UNITY_STANDALONE
Application.Quit();
#endif
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
and
#if UNITY_STANDALONE
AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
activity.Call<bool>("moveTaskToBack", true);
#endif
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
In both cases nothing happens when I click the Quit button.
In Unity editor this code works and application stops playing.