I am developing an application that periodically sends data through an UDP socket. For the moment, my code worked well until I tried to test the application with Android.
The code that I am using is:
m_outputSocket.writeDatagram (data, QHostAddress (robotAddress()), m_outputPort);
I have set the following permissions accordingly on the AndroidManifest.xml file:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
Update, I also added the INTERNET permission, but it still does not work
<uses-permission android:name="android.permission.INTERNET"/>
Running on Android, my application fails to send and receive data through UDP sockets. As a side note, the writeDatargram
function returns -1 (indicating an error according to Qt's documentation).
Notes:
- I am using Qt 5.6 with the Android SDK v19
- The code works on Windows and Linux, but not on Android
- The
writeDatagram
function returns -1 - I have set permissions accordingly on the AndroidManifest.xml file
- I have tried this solution, but the application crashes while initializing.
Is there anything that can be done to get UDP working on Android with Qt?