diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/bluetooth/pingpong/pingpong.cpp | 11 | ||||
-rw-r--r-- | examples/bluetooth/pingpong/pingpong.h | 3 | ||||
-rw-r--r-- | examples/bluetooth/pingpong/pingpong.pro | 1 |
3 files changed, 14 insertions, 1 deletions
diff --git a/examples/bluetooth/pingpong/pingpong.cpp b/examples/bluetooth/pingpong/pingpong.cpp index ab6ba8c7..58d5ff2f 100644 --- a/examples/bluetooth/pingpong/pingpong.cpp +++ b/examples/bluetooth/pingpong/pingpong.cpp @@ -40,6 +40,9 @@ #include "pingpong.h" #include <QDebug> +#ifdef Q_OS_ANDROID +#include <QtAndroid> +#endif PingPong::PingPong(): m_serverInfo(0), socket(0), discoveryAgent(0), interval(5), m_resultLeft(0), m_resultRight(0), @@ -253,8 +256,16 @@ void PingPong::startClient() connect(discoveryAgent, SIGNAL(finished()), this, SLOT(done())); connect(discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceScanError(QBluetoothServiceDiscoveryAgent::Error))); +#ifdef Q_OS_ANDROID //see QTBUG-61392 + if (QtAndroid::androidSdkVersion() >= 23) + discoveryAgent->setUuidFilter(QBluetoothUuid(androidUuid)); + else + discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid)); +#else discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid)); +#endif discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); + //! [Searching for the service] setMessage(QStringLiteral("Starting server discovery. You are the right player")); // m_role is set to 2 if it is a client diff --git a/examples/bluetooth/pingpong/pingpong.h b/examples/bluetooth/pingpong/pingpong.h index 650cd597..21c9ef1c 100644 --- a/examples/bluetooth/pingpong/pingpong.h +++ b/examples/bluetooth/pingpong/pingpong.h @@ -48,7 +48,8 @@ #include <qbluetoothlocaldevice.h> #include <qbluetoothservicediscoveryagent.h> -static const QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9")); +static QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9")); +static QString androidUuid(QStringLiteral("c9e96402-0102-cf9c-274b-701a950fe1e8")); class PingPong: public QObject { diff --git a/examples/bluetooth/pingpong/pingpong.pro b/examples/bluetooth/pingpong/pingpong.pro index 07675f27..aa79212e 100644 --- a/examples/bluetooth/pingpong/pingpong.pro +++ b/examples/bluetooth/pingpong/pingpong.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = pingpong QT += quick bluetooth +android: QT += androidextras # Input SOURCES += main.cpp \ |