This repository was archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (46 loc) · 1.71 KB
/
main.cpp
File metadata and controls
61 lines (46 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <QtCore>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>
#include "quickandroid.h"
#include "qadrawableprovider.h"
#include "qasystemdispatcher.h"
#include "automator.h"
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QAndroidJniObject>
#include <QtAndroidExtras/QAndroidJniEnvironment>
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
Q_UNUSED(vm);
qDebug("NativeInterface::JNI_OnLoad()");
// It must call this function within JNI_OnLoad to enable System Dispatcher
QASystemDispatcher::registerNatives();
/* Optional: Register your own service */
// Call quickandroid.example.ExampleService.start()
QAndroidJniObject::callStaticMethod<void>("quickandroid/example/ExampleService",
"start",
"()V");
return JNI_VERSION_1_6;
}
#endif
int main(int argc, char *argv[])
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
/* QuickAndroid Initialization */
engine.addImportPath("qrc:///"); // Add QuickAndroid into the import path
/* End of QuickAndroid Initialization */
// Extra features:
QADrawableProvider* provider = new QADrawableProvider();
provider->setBasePath("qrc://res");
engine.addImageProvider("drawable",provider);
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
/* Testing Code. Not needed for regular project */
Automator* automator = new Automator();
automator->start();
qDebug() << "Start QuickAndroid Example Program";
return app.exec();
}