-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOpenAndroidGallery.cpp
48 lines (36 loc) · 1.12 KB
/
OpenAndroidGallery.cpp
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
#include "OpenAndroidGallery.h"
#include <QtAndroidExtras/QAndroidJniObject>
#include <QCoreApplication>
#include <QFile>
#include <QDebug>
QString selectedFileName;
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL
Java_org_qtproject_example_QtAndroidGallery_fileSelected(JNIEnv */*env*/,
jobject /*obj*/,
jstring results)
{
selectedFileName = QAndroidJniObject(results).toString();
}
#ifdef __cplusplus
}
#endif
OpenAndroidGallery::OpenAndroidGallery(QObject *parent) : QObject(parent)
{
}
void OpenAndroidGallery::openGallery()
{
selectedFileName = "#";
QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/QtAndroidGallery",
"openAnImage",
"()V");
while(selectedFileName == "#")
qApp->processEvents();
if(QFile(selectedFileName).exists())
{
qDebug() << "selectedFileName ;; " << selectedFileName ;
emit sigSendPath(selectedFileName);
}
}