]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/android/mainthread.cpp
Minimalistic port for Android
[libs/core.git] / source / core / android / mainthread.cpp
diff --git a/source/core/android/mainthread.cpp b/source/core/android/mainthread.cpp
new file mode 100644 (file)
index 0000000..51fcafc
--- /dev/null
@@ -0,0 +1,31 @@
+#include <cstring>
+#include <msp/fs/path.h>
+#include "application.h"
+#include "errorlogger.h"
+#include "mainthread.h"
+
+using namespace std;
+
+namespace Msp {
+namespace Android {
+
+MainThread::MainThread(ANativeActivity *a):
+       activity(a)
+{
+       launch();
+}
+
+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 *argv[] = { appname, 0 };
+       Msp::Android::ErrorLogger err_logger;
+       Msp::Application::run(1, argv, activity);
+       free(appname);
+       ANativeActivity_finish(activity);
+}
+
+} // namespace Android
+} // namespace Msp