Unsolved Qt + Android and WiFi
-
Hello,
I am writing an app for an android device and i am wondering if it is possible to enable and disable the Wifi within my app?
Best regards
-
Hi and welcome to devnet,
I haven't tested that with Android but the Bearer Manager might be what your are looking for.
Hope it helps
-
Hi,
Yes, i read the article. When i run
QNetworkConfigurationManager manager; const bool canStartIAP = (manager.capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces);
canStartIAP is false. My app has all permissions to edit the wifi state.
Furthermore, wheni try the following code:QNetworkConfigurationManager ncm; QList<QNetworkConfiguration> nc = ncm.allConfigurations(); foreach( QNetworkConfiguration item, nc ) { if (item.bearerType() == QNetworkConfiguration::BearerWLAN) { qDebug() << "Wifi" << item.name(); qDebug() << "state" << item.state(); } }
then i see that my app knows that there exist a mobile and wifi network but the state is alway 0x2.
I am also able to use androidextras to run java code and use the wifimanager to switch on wifi (which works), but it would be nicer to use Qt-Code only...Best regards
-
From a quick look at the code, it seams that changing the connection state is currently not supported so you are on the correct track using the QtAndroidExtras module
-
Thanks for your advice.
I've got one more question:On my Android device the QNetworkConfigurationManager only lists "Mobile" and "Wifi" but not the names of the available WLANs. Does this have to be done externally as well?
-
Did you call QNetworkConfigurationManager::updateConfigurations ?
-
Yes, i did.
-
Which version of Android ?
-
My device runs android 5.1.1 and i am using Qt 5.5.1.
-
Since Qt 5.6.0 is out, can you check again with it ?