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
56 lines (44 loc) · 1.65 KB
/
main.cpp
File metadata and controls
56 lines (44 loc) · 1.65 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>
#include "quickandroid.h"
#include "qadrawableprovider.h"
#include "qasystemdispatcher.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()");
QASystemDispatcher::registerNatives();
return JNI_VERSION_1_6;
}
#endif
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQuickView view;
/* QuickAndroid Initialization */
view.engine()->addImportPath("qrc:///"); // Add QuickAndroid into the import path
QuickAndroid::registerTypes(); // It must be called before loaded any scene
/* End of QuickAndroid Initialization */
// Extra features:
QADrawableProvider* provider = new QADrawableProvider();
provider->setBasePath("qrc:///");
view.engine()->addImageProvider("drawable",provider);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl(QStringLiteral("qrc:///main.qml")));
view.show();
QVariantMap message;
message["field1"] = "value1";
message["field2"] = 10;
message["field3"] = true;
QASystemDispatcher::instance()->dispatch("ping",message);
message.clear();
message["title"] = "Quick Android Example";
message["message"] = "Hello! It is Quick Android Hello World";
QASystemDispatcher::instance()->dispatch("notificationManagerNotify",message);
view.rootContext()->setContextProperty("SystemMessenger",QASystemDispatcher::instance());
return app.exec();
}