Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Send data through wifi (no internet) when mobile data on
zenghsing last edited by zenghsing
I'm using Qt & QML to develop an application that connects to a hardware device through wifi (generated by the device) and send data to it through a socket connection too. The problem is that when mobile data (3G/4G) is activated android tries to send the data through it instead of sending it through the wifi generated by the device. The issue is the same with the below post link:
Now, I use QUdpSocket* and QTcpSocket* to bind and connectToHost Machine. I don't know how to add the addTransportType(NetworkCapabilities.TRANSPORT_WIFI) code to my Qt project. Is it possible to call that like the below sentence:
QAndroidJniObject XXX_ObjectName = QAndroidJniObject::fromString("XXX_Key_Word");
And how to do?
Gojir4 last edited by Gojir4
You need to define static java method and then call it from C++ using QAndroidJniObject::callStaticMethod()
See the Qt Notifier example. It shows how to display Android notification by calling a static java method and I think it's pretty similar to what you need.
edit: This is only a solution for calling java method from C++, I'm not sure if this will fix your issue as you are using QAbstractSocket* mechanisms.