Forum Discussion
DoubleDenim
5 years agoProtege
How to capture exit event on exiting from the OS on Quest
Anyone know which event to handle to get in before the OS terminates the app in Unreal to do an auto save on exit?
On PC in Unreal the Game instance's Shutdown event works but not on Quest.
So the user scenario is when you click terminate app in the Oculus menu bar, how does the app know it's being terminated in Unreal?
On PC in Unreal the Game instance's Shutdown event works but not on Quest.
So the user scenario is when you click terminate app in the Oculus menu bar, how does the app know it's being terminated in Unreal?
4 Replies
Replies have been turned off for this discussion
- shienaProtegeApplication Will Terminate Delegate
https://docs.unrealengine.com/en-US/BlueprintAPI/EventDispatchers/ApplicationWillTerminateDelegate/index.html
or Application Will Enter Background Delegate
https://docs.unrealengine.com/en-US/BlueprintAPI/EventDispatchers/ApplicationWillEnterBackgroundDe-/index.html
see also
https://forums.unrealengine.com/development-discussion/ios-development/47790-how-to-auto-save-upon-exit-app-can-t-find-application-will-terminate-event - ysquallProtege
I try using "Application Will Terminate Delegate" or "Application Will Enter Background Delegate" but neither seem to work. any other solution?
- dario.macielStart Member
you need to enable the app to write on external storage (android permissions, i recommend doing this on begin play of the app),
- meloinExplorer
Because ouclus sdk didnt implement Application Will Terminate Delegate with oculus you need to use native java method in unreal. That what I did.
1. Added JNI native method at GameInstance as
extern "C" JNIEXPORT void JNICALL Java_com_epicgames_ue4_GameActivity_OnAppTerminated(JNIEnv* jenv, jobject thiz)
{
UPVPGameInstance::NotifyServerLeaving(); // this is static method
UE_LOG(LogTemp, Error, TEXT("ApplicationWillTerminateDelegate"));
}
2. Added UPL XML with code and included it on build:
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:android="http://schemas.android.com/apk/res/android">
<!-- optional additions to the GameActivity class in GameActivity.java -->
<gameActivityClassAdditions>
<insert>
<![CDATA[
private native void OnAppTerminated();
]]>
</insert>
</gameActivityClassAdditions>
<!-- -->
<gameActivityOnDestroyAdditions>
<insert>
<![CDATA[
OnAppTerminated();
]]>
</insert>
</gameActivityOnDestroyAdditions>
</root>3. If you are developing multiplayer game and would like to notify server about that exit you need to send custom udp message on server (you can't do http because you need time for handshake and you have no time for it)
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 months ago
- 8 months ago
- 4 months ago