diff options
Diffstat (limited to 'examples/bluetooth/btchat')
-rw-r--r-- | examples/bluetooth/btchat/btchat.pro | 1 | ||||
-rw-r--r-- | examples/bluetooth/btchat/chat.cpp | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/examples/bluetooth/btchat/btchat.pro b/examples/bluetooth/btchat/btchat.pro index 08fdd4a7..6ecae4c7 100644 --- a/examples/bluetooth/btchat/btchat.pro +++ b/examples/bluetooth/btchat/btchat.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = btchat QT = core bluetooth widgets +android: QT += androidextras SOURCES = \ main.cpp \ diff --git a/examples/bluetooth/btchat/chat.cpp b/examples/bluetooth/btchat/chat.cpp index 51a2d4ed..929a42e4 100644 --- a/examples/bluetooth/btchat/chat.cpp +++ b/examples/bluetooth/btchat/chat.cpp @@ -49,11 +49,18 @@ #include <qbluetoothdeviceinfo.h> #include <qbluetoothlocaldevice.h> +#ifdef Q_OS_ANDROID +#include <QtAndroidExtras/QtAndroid> +#endif + #include <QTimer> #include <QDebug> static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8"); +#ifdef Q_OS_ANDROID +static const QLatin1String reverseUuid("c8e96402-0102-cf9c-274b-701a950fe1e8"); +#endif Chat::Chat(QWidget *parent) : QDialog(parent), currentAdapterIndex(0), ui(new Ui_Chat) @@ -170,7 +177,14 @@ void Chat::connectClicked() localAdapters.at(currentAdapterIndex).address(); RemoteSelector remoteSelector(adapter); +#ifdef Q_OS_ANDROID + if (QtAndroid::androidSdkVersion() >= 23) + remoteSelector.startDiscovery(QBluetoothUuid(reverseUuid)); + else + remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid)); +#else remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid)); +#endif if (remoteSelector.exec() == QDialog::Accepted) { QBluetoothServiceInfo service = remoteSelector.service(); |