X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fandroid%2Fmainthread.cpp;h=d394f838bcd497495255dc14296313f546a7813f;hp=1e5fc1198072ef48cc84c48fead2436bcba3e39b;hb=264195348a606f22f9d50348cd03b93b49175acc;hpb=53ce154a2e446e82815034cb65a81b6784a767f5 diff --git a/source/core/android/mainthread.cpp b/source/core/android/mainthread.cpp index 1e5fc11..d394f83 100644 --- a/source/core/android/mainthread.cpp +++ b/source/core/android/mainthread.cpp @@ -1,5 +1,8 @@ #include +#include +#include #include +#include #include "application.h" #include "errorlogger.h" #include "mainthread.h" @@ -10,6 +13,8 @@ namespace Msp { namespace Android { MainThread::MainThread(ANativeActivity *a): + asset_manager(a->assetManager), + int_data_path(a->internalDataPath), starting_up(true) { attach_to_activity(a); @@ -47,13 +52,19 @@ void MainThread::main() { /* I have no idea how dependable this is, but it seems to be the only way to get the package name aside from making a Java call through JNI */ - char *appname = strdup(FS::Path(activity->internalDataPath)[-2].c_str()); + char *appname = strdup(int_data_path[-2].c_str()); char *argv[] = { appname, 0 }; Msp::Android::ErrorLogger err_logger; + FS::chdir(FS::dirname(int_data_path)); 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) @@ -91,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