From: Mikko Rasa Date: Thu, 13 Nov 2014 20:44:51 +0000 (+0200) Subject: Terminate the process when the application has finished running X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=264195348a606f22f9d50348cd03b93b49175acc;p=libs%2Fcore.git 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. --- 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