diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-04-06 12:38:16 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-04-13 07:46:59 +0000 |
commit | aecf1408552a440b81b1157c4f701533833c09c8 (patch) | |
tree | 3ba6f9118b3ed18504edde988db253bdac7603d1 | |
parent | 20b0a09547131cf0d01f7373735c4382843461bd (diff) | |
download | qtconnectivity-aecf1408552a440b81b1157c4f701533833c09c8.tar.gz |
Fix Annotated URL Example on Android
QNearFieldManager::registerNdefMessageHandler() is supposed to register
the current app as platform handler for certain tag types. The example
is written around this concept and doesn't start the target detection
when such a registration succeeded.
Unfortunately the Android implementation does something completely
different. Therefore the startTargetDetection() and connect() calls
after the current return is necessary to make the example useful.
For now we simply ignore the feature and always start target
detection. Since neither NEARD/Linux nor Android (the only two
supported platforms) have an implementation for the feature
the modified example works as expected.
Considering the current state it should be considered to remove
this NDEF message registration feature in Qt 6 altogether. The only platform
which ever supported the feature was BB10 and its implementation was
removed a long time ago.
Task-number: QTBUG-52154
Change-Id: Ibef9e77ac33b9629b6d81aa70eaa01ab1702cfcb
Reviewed-by: Peter Rustler <peter.rustler@basyskom.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r-- | examples/nfc/annotatedurl/annotatedurl.cpp | 4 | ||||
-rw-r--r-- | src/nfc/qnearfieldmanager.h | 4 | ||||
-rw-r--r-- | src/nfc/qnearfieldmanager_android.cpp | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/examples/nfc/annotatedurl/annotatedurl.cpp b/examples/nfc/annotatedurl/annotatedurl.cpp index cf7dd17a..a07aadcc 100644 --- a/examples/nfc/annotatedurl/annotatedurl.cpp +++ b/examples/nfc/annotatedurl/annotatedurl.cpp @@ -77,8 +77,8 @@ AnnotatedUrl::AnnotatedUrl(QObject *parent) SLOT(handleMessage(QNdefMessage,QNearFieldTarget*))); //! [QNearFieldManager register handler] - if (result != -1) - return; + if (result < 0) + qWarning() << "Platform does not support NDEF message handler registration"; manager->startTargetDetection(); connect(manager, SIGNAL(targetDetected(QNearFieldTarget*)), diff --git a/src/nfc/qnearfieldmanager.h b/src/nfc/qnearfieldmanager.h index 8c91a801..c367d875 100644 --- a/src/nfc/qnearfieldmanager.h +++ b/src/nfc/qnearfieldmanager.h @@ -71,6 +71,10 @@ public: bool startTargetDetection(); void stopTargetDetection(); + //TODO Qt 6 Consider removal of this registration mechanism + //None of the currently supported platforms supports the feature + //or in fact the implementation (on Android) is not what the + //function is supposed to do. int registerNdefMessageHandler(QObject *object, const char *method); int registerNdefMessageHandler(QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type, diff --git a/src/nfc/qnearfieldmanager_android.cpp b/src/nfc/qnearfieldmanager_android.cpp index d1434840..d601a159 100644 --- a/src/nfc/qnearfieldmanager_android.cpp +++ b/src/nfc/qnearfieldmanager_android.cpp @@ -186,6 +186,10 @@ void QNearFieldManagerPrivateImpl::stopTargetDetection() updateReceiveState(); } +// FIXME This is supposed to be a platform registration. A message that +// matches the given NDEF filter should restart the current application. +// The implementation below only works as long as the current application +// is running. It is not a platform wide registration on Android. int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(QObject *object, const QMetaMethod &method) { ndefMessageHandlers.append(QPair<QPair<int, QObject *>, QMetaMethod>(QPair<int, QObject *>(m_handlerID, object), method)); @@ -194,6 +198,7 @@ int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(QObject *object, co return m_handlerID++; } +// FIXME see above int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(const QNdefFilter &filter, QObject *object, const QMetaMethod &method) { |