Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice
  2. 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:
    333
    Bump. Running into the same issue. Anyone using any alternatives on the Quest?
     
  4. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    306
    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:
    333
    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.
  7. emerge-sjh

    emerge-sjh

    Joined:
    Oct 16, 2020
    Posts:
    13
    Not sure how this got marked resolved. @mfuad did a ticket ever get submitted for this?
     
unityunity