2

Please consider the following snippet of Code:

QNetworkAccessManager* netManager = new QNetworkAccessManager(this);    
if(netManager->networkAccessible() == QNetworkAccessManager::UnknownAccessibility)
{
    Utilities::showToast("UnknownAccessibility", "Retry");
}
if(netManager->networkAccessible() == QNetworkAccessManager::NotAccessible)
{
    Utilities::showToast("NotAccessible", "Retry");
}
if(netManager->networkAccessible() == QNetworkAccessManager::Accessible)
{
    Utilities::showToast("Accessible", "Retry");
}

This permanently returns -1. Is there another way to detect Data and Wifi settings for BB Native?

Ben Pretorius
  • 4,079
  • 4
  • 34
  • 28
  • 1
    I have also tried the following addition to the above mentioned code: QNetworkConfigurationManager configManager; netManager->setConfiguration(configManager.defaultConfiguration()); – Ben Pretorius Dec 04 '13 at 09:40

1 Answers1

1

You might be using an old version of BB10. I looked at the git history for qnetworkaccessmanager.h and it seems that this class was updated after 10.0. For instance the commit:

commit 9efd40bd776e1c5e7ce9feeac63b3673250291b6 Date: Thu Feb 28 17:41:59 2013 +0100

QNetworkAccessManager: track online / accessible state without session

In particular, set online state right upon construction of the
QNetworkAccessManager instance. Therefor, QNAM needs an instance of a
QNetworkConfigurationManager internally.
Before, this would only work properly if a network session was created.
Now, networkAccessible() returns the correct status.

Seems to indicate that on BB10.0, the networkAccessible() would work correctly if a network session was created (and opened).

nbilal
  • 1,069
  • 2
  • 10
  • 21