Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question AR Foundation - Android App does not want to quit, but simply minimizes

Discussion in 'AR' started by newguy123, Feb 17, 2023.

  1. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,231
    Hi Guys

    I have a canvas button with some code, to quit my app. However on Android the app does not quit, but it simply goes to the background, ie it keeps running. How can I get it to properly quit?

    Here is my code I'm currently using:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class SwitchScenes : MonoBehaviour {
    7.  
    8.     public void QuitApp()
    9.     {
    10.         #if UNITY_EDITOR
    11.             // Application.Quit() does not work in the editor so
    12.             // UnityEditor.EditorApplication.isPlaying need to be set to false to end the game
    13.             UnityEditor.EditorApplication.isPlaying = false;
    14.         #else
    15.             Application.Quit();
    16.         #endif
    17.     }
    18.  
    19.     public void Awake()
    20.     {
    21.         Screen.sleepTimeout = SleepTimeout.NeverSleep;
    22.     }
    23.  
    24. }
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    718
  3. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,231
    The problem is actualy deeper than this @andyb-unity when I try to quit the app:
    On Android the app just goes to background
    On iOS it crashes
     
  4. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Are you running any threads?
     
  5. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,231
    unlikely, seeing that I have no idea what that is
     
  6. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    718
    Are you able to reproduce this issue in our Samples app? It sounds like something else in your project might be causing the behavior you describe.