#include <cstring>
+#include <cstdlib>
+#include <msp/fs/dir.h>
#include <msp/fs/path.h>
+#include <msp/fs/utils.h>
#include "application.h"
#include "errorlogger.h"
#include "mainthread.h"
MainThread::MainThread(ANativeActivity *a):
asset_manager(a->assetManager),
+ int_data_path(a->internalDataPath),
starting_up(true)
{
attach_to_activity(a);
{
/* 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)
reinterpret_cast<MainThread *>(activity->instance)->signal_input_queue_destroyed.emit(queue);
}
+void MainThread::end_process(ANativeActivity *)
+{
+ exit(0);
+}
+
} // namespace Android
} // namespace Msp