Usage of specific QNetworkConfiguration on android
Unsolved
Mobile and Embedded
-
Hi,
I work on android application that needs to connect to a server in a WLAN. The problem is that this WLAN does not have internet access, so on some devices it is not set as default network configuration in QNetworkAccessManager::activeConfiguration()
I found the required config in QNetworkConfigurationManager::allConfigurations() but I dont have an idea how can I force QTcpSocket to use this instead of the default one. I tried to do this for example in this way:
(Sorry for the ugly code - it is just for test as I am currently looking for some solution)QNetworkConfigurationManager configurationsManager; auto configurations = configurationsManager.allConfigurations(); for ( auto config : configurations ) { auto b = config.bearerType(); if ( b == QNetworkConfiguration::BearerWLAN ) { auto networkSession = new QNetworkSession( currentConfiguration ); networkSession->open(); networkSession->waitForOpened(); QNetworkConfiguration config = networkSession->configuration(); QString id; if (config.type() == QNetworkConfiguration::UserChoice) id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); else id = config.identifier(); QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); settings.endGroup(); break; } }
But it did not help at all... Do you know how can I change the active configuration or pass it to the QTcpSocket to force it to use this interface?
Best Regards,
Patryk