From 264195348a606f22f9d50348cd03b93b49175acc Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 13 Nov 2014 22:44:51 +0200 Subject: [PATCH] Terminate the process when the application has finished running Otherwise the OS may try to start the activity again in the same process, which doesn't work because of Application::run semantics. --- source/core/android/mainthread.cpp | 11 +++++++++++ source/core/android/mainthread.h | 1 + 2 files changed, 12 insertions(+) diff --git a/source/core/android/mainthread.cpp b/source/core/android/mainthread.cpp index 473379b..d394f83 100644 --- a/source/core/android/mainthread.cpp +++ b/source/core/android/mainthread.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -58,7 +59,12 @@ void MainThread::main() Msp::Application::run(1, argv, this, &app_created); free(appname); if(activity) + { + activity->callbacks->onDestroy = &end_process; ANativeActivity_finish(activity); + } + else + end_process(0); } void MainThread::app_created(void *data) @@ -96,5 +102,10 @@ void MainThread::input_queue_destroyed(ANativeActivity *activity, AInputQueue *q reinterpret_cast(activity->instance)->signal_input_queue_destroyed.emit(queue); } +void MainThread::end_process(ANativeActivity *) +{ + exit(0); +} + } // namespace Android } // namespace Msp diff --git a/source/core/android/mainthread.h b/source/core/android/mainthread.h index 4bac952..09f907f 100644 --- a/source/core/android/mainthread.h +++ b/source/core/android/mainthread.h @@ -47,6 +47,7 @@ private: static void native_window_destroyed(ANativeActivity *, ANativeWindow *); static void input_queue_created(ANativeActivity *, AInputQueue *); static void input_queue_destroyed(ANativeActivity *, AInputQueue *); + static void end_process(ANativeActivity *); }; } // namespace Android -- 2.45.2