summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qjnihelpers.cpp
diff options
context:
space:
mode:
authorPeter Rustler <peter.rustler@basyskom.com>2015-01-09 16:14:17 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-01-21 12:13:25 +0100
commitf93c04e44a5bd08fea76a1147b1aa51953bce925 (patch)
tree210e9f2e0162da6471ccec98c0529943e98984f8 /src/corelib/kernel/qjnihelpers.cpp
parentc87566bf9eb8e699aa1400876c1e314ff62f59fe (diff)
Added new private API for Android and onNewIntent
On Android the foreground activity can get intents with onNewIntent. Those intents can not be received in any other way. This is especially true in Android nfc. This patch adds a way to receive those intents in Qt. This patch heavily leans on the implementation of onActivityResult. Change-Id: Ic4dca301f34afe9a528149c3653e545ed3265a3c Reviewed-by: BogDan Vatra <bogdan@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/corelib/kernel/qjnihelpers.cpp')
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index d3bbce305a..2ba2645f2c 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -89,6 +89,39 @@ void QtAndroidPrivate::handleActivityResult(jint requestCode, jint resultCode, j
}
}
+namespace {
+ class NewIntentListeners
+ {
+ public:
+ QMutex mutex;
+ QList<QtAndroidPrivate::NewIntentListener *> listeners;
+ };
+}
+
+Q_GLOBAL_STATIC(NewIntentListeners, g_newIntentListeners)
+
+void QtAndroidPrivate::registerNewIntentListener(NewIntentListener *listener)
+{
+ QMutexLocker locker(&g_newIntentListeners()->mutex);
+ g_newIntentListeners()->listeners.append(listener);
+}
+
+void QtAndroidPrivate::unregisterNewIntentListener(NewIntentListener *listener)
+{
+ QMutexLocker locker(&g_newIntentListeners()->mutex);
+ g_newIntentListeners()->listeners.removeAll(listener);
+}
+
+void QtAndroidPrivate::handleNewIntent(JNIEnv *env, jobject intent)
+{
+ QMutexLocker locker(&g_newIntentListeners()->mutex);
+ const QList<QtAndroidPrivate::NewIntentListener *> &listeners = g_newIntentListeners()->listeners;
+ for (int i=0; i<listeners.size(); ++i) {
+ if (listeners.at(i)->handleNewIntent(env, intent))
+ break;
+ }
+}
+
static inline bool exceptionCheck(JNIEnv *env)
{
if (env->ExceptionCheck()) {