No 'exitEvent' when app is killed on Android
See original GitHub issueDid you verify this is a real problem by searching [Stack Overflow]
Yes, I’ve also searched in the issues here and found the same issue reported: #438 But sadly that ticket is closed without a solution.
Which platform(s) does your issue occur on?
Android
Please provide the following version numbers that your issue occurs with:
- CLI: 3.1.3
- Cross-platform modules: 3.1.0
- Runtime(s): 3.1.1
Please tell us how to recreate the issue in as much detail as possible.
I’m starting my plain TypeScript (without Angular) app. When I exit (or kill) the app, the event does not get fired. The event doesn’t even get fired when I kill my app via button like the following: android.os.Process.killProcess(android.os.Process.myPid());
I need to mention that the suspendEvent
is logged without any issues, as well as the launchEvent
and the resumeEvent
. Only exitEvent
doesn’t get triggered.
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
...
application.on(app.launchEvent, (args: app.ApplicationEventData) => {
console.log('app.ts -> launchEvent');
});
application.on(application.resumeEvent, (args: application.ApplicationEventData) => {
console.log("app.ts -> resumeEvent");
});
application.on(application.suspendEvent, (args: application.ApplicationEventData) => {
console.log('app.ts -> suspendEvent');
});
application.on(application.exitEvent, (args: application.ApplicationEventData) => {
console.log('app.ts -> exitEvent');
});
app.start({ moduleName: 'pages/main/main' });
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to close Android application? - Stack Overflow
Android has a mechanism in place to close an application safely per its documentation. In the last Activity that is exited (usually the...
Read more >ApplicationExitInfo - Android Developers
Application process was killed because its dependency was going away, for example, a stable content provider connection's client will be killed if the ......
Read more >How do I detect the exit of an App in Android? - CodeProject
onDestroy() and onStop() wouldn't be fired if app is closed from recent apps list or killed by android system. But there may be...
Read more >App lifecycle - .NET MAUI | Microsoft Learn
NET MAUI raises cross-platform lifecycle events when an app transitions between its different execution states.
Read more >Determine if the App is terminated by the User or by iOS
-applicationWillTerminate: is called when the user terminates your app from the multitasking UI while your app is in the foreground. You should test...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the explanation, @NickIliev!
Now I can understand why this app doesn’t throw this event. But I’m still facing some serious issues because of that. My app plays a some voice via TTS (https://github.com/bradmartin/nativescript-texttospeech) and I want the app to stop talking, as soon as the app gets closed. Currently the speech engine doesn’t stop talking, when I kill the app. That’s somewhat annoying. And I don’t want it to stop when I minimize it (
suspendEvent
). Any ideas or recommendations?Thanks @NickIliev, but I’m aware of how the events usually work. As I stated earlier, the
resumeEvent
fires as expect, when I minimize the app.What circumstances could cause my issue, that the
exitEvent
doesn’t get fired, even when I kill the process like I described in my initial post? I would expect the event to be fired, no matter if I kill the process via Android command (see above) or if I just close the window in the task manager, or select “kill all” in the task manager. I don’t receive theexitEvent
. 😞