Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity wants to learn about your experiences working on a Unity project today. We'd like to hear from you via this survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  4. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Resolved OnApplicationQuit() and OnDestroy() is not executed when exit app on Oculus Quest!

Discussion in 'VR' started by BelieveXiaoShuai, Dec 18, 2019.

  1. BelieveXiaoShuai

    BelieveXiaoShuai

    Joined:
    Nov 6, 2017
    Posts:
    13
    I am developing VR applications on oculus Quest when I press the Oculus Home button and return to Oculus Platform UI Exit Prompt, OnApplicationPause () and OnApplicationFoundations () execute normally, but when I choose the Exit button to exit my application, the application exits, but OnApplicationQuit () and OnDestroy () are not executed.
     

    Attached Files:

    Last edited: Dec 18, 2019
  2. BelieveXiaoShuai

    BelieveXiaoShuai

    Joined:
    Nov 6, 2017
    Posts:
    13
    On AndroidLogCat, I see this below.
    Unity know app is quit but not notice OnApplicationQuit() and OnDestroy().
     

    Attached Files:

  3. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    331
    Bump. Running into the same issue. Anyone using any alternatives on the Quest?
     
  4. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    305
    Hi @hungrybelome, can you file a bug with reproducible project so the team can properly track and take a look? Thanks!
     
  5. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    331
    Hi, I ended up just using OnApplicationPause(), which works fine!
     
    mfuad likes this.
  6. mmmshuddup

    mmmshuddup

    Joined:
    Feb 9, 2015
    Posts:
    4
    @mfuad How is this thread marked as "Resolved" when it's evidently not resolved? This has been an ongoing issue since the Oculus Go days. It apparently has something to do with the inherent behavior of android which suspends applications.

    OnApplicationPause DOES NOT SUFFICE! App quit logic is very different from app pause logic.

    The Oculus Integration package should come with a built-in android plugin written in Java which hooks into the application suspend event and automatically call some function or event which users such as ourselves can hook into. If you guys don't want it to call `OnApplicationQuit()` then that is fine, but you can at least make a custom event and event listener so that we can do something like:

    Code (CSharp):
    1. private void Awake()
    2. {
    3.     OVRPlugin.applicationSuspend += OnApplicationSuspend();
    4. }
    5.  
    6. private void OnApplicationSuspend()
    7. {
    8.     // app quit logic such as leave game, etc
    9. }
    Is it really that hard for Oculus to build a Java plugin that hooks into the C# API like that?
     
    confy, jeromeWork and hungrybelome like this.
unityunity