Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
Posts: 8
Registered: ‎02-27-2013
My Device: BlackBerry 10 Dev Alpha
My Carrier: no

Checking of internet connection

Hi

I try to check internet connection on the devise with this code:

/**
 * Check Internet Connectivity
 */
bool QBUsers::checkConnect() {
	QNetworkConfigurationManager netMgr;
	QList<QNetworkConfiguration> mNetList = netMgr.allConfigurations(
			QNetworkConfiguration::Active);
	if (mNetList.count() > 0) {
		if (netMgr.isOnline()) {
			mNetList.clear();
			netMgr.deleteLater();
			return true;
		} else {
			mNetList.clear();
			netMgr.deleteLater();
			return false;
		}
	} else {
		mNetList.clear();
		netMgr.deleteLater();
		return false;
	}
}

When i pressed the key (first time) - i get the false, but i must get true. But after the second pressed i get true. Could you explain me the behavior?

 

Thanks!