如何在BlackBerry 10.2中检测网络状态

时间:2014-09-20 16:33:03

标签: blackberry blackberry-10 blackberry-cascades

我想检测网络状态。我在bb 10.2中找到了两种寻找互联网连接的方法,但似乎没有人工作:

1:它总是返回" QNetworkAccessManager :: UnknownAccessibility"

QNetworkAccessManager* networkAccessManager = new QNetworkAccessManager(this);
networkAccessManager->networkAccessible();

2:它总是返回

QNetworkConfigurationManager *manager = new QNetworkConfigurationManager();
bool res = QObject::connect(manager,
                SIGNAL(onlineStateChanged(bool)),
                this,
                SLOT(onOnlineStateChanged(bool)));
Q_ASSERT(res);

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

解决方案是使用QNetworkConfigurationManager::isOnline()

QNetworkConfigurationManager *manager = new QNetworkConfigurationManager();
Q_ASSERT(manager->isOnline());