]> git.tdb.fi Git - libs/core.git/blob - source/core/android/mainthread.cpp
Minimalistic port for Android
[libs/core.git] / source / core / android / mainthread.cpp
1 #include <cstring>
2 #include <msp/fs/path.h>
3 #include "application.h"
4 #include "errorlogger.h"
5 #include "mainthread.h"
6
7 using namespace std;
8
9 namespace Msp {
10 namespace Android {
11
12 MainThread::MainThread(ANativeActivity *a):
13         activity(a)
14 {
15         launch();
16 }
17
18 void MainThread::main()
19 {
20         /* I have no idea how dependable this is, but it seems to be the only way
21         to get the package name aside from making a Java call through JNI */
22         char *appname = strdup(FS::Path(activity->internalDataPath)[-2].c_str());
23         char *argv[] = { appname, 0 };
24         Msp::Android::ErrorLogger err_logger;
25         Msp::Application::run(1, argv, activity);
26         free(appname);
27         ANativeActivity_finish(activity);
28 }
29
30 } // namespace Android
31 } // namespace Msp