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
Contributor
KishoreTalloju
Posts: 28
Registered: ‎07-04-2013
My Device: BB, 86ABC
My Carrier: IDEA

How to check whether internet is enbled or disabled?

I need check internet is available or not before calling a service in my Application.

I used following code but its not working.

 

QNetworkAccessManager manager;
if (manager.networkAccessible() == QNetworkAccessManager::Accessible) {
    // Internet available.
}

 

every time its returning false.

Can any one help me?

Thanks in advance.

QNetworkAccessManager manager;
if (manager.networkAccessible() == QNetworkAccessManager::Accessible) {
    // Internet available.
}
Please use plain text.
Developer
hemant_sain
Posts: 178
Registered: ‎12-09-2011
My Device: 9360, BB10
My Carrier: Aircel

Re: How to check whether internet is enbled or disabled?

Please use plain text.
BlackBerry Development Advisor
sabdelsayed
Posts: 249
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: How to check whether internet is enbled or disabled?

[ Edited ]

Hi KishoreTalloju,

 

Here is another way to check if the device is connected to the internet: 

 

	bool available = false;
	QNetworkConfigurationManager netMgr;
	QList<QNetworkConfiguration> mNetList = netMgr.allConfigurations(QNetworkConfiguration::Active);
	if (mNetList.count() > 0) {
		if (netMgr.isOnline()) {
			available = true;
			qDebug()<< "internet available";
		}
	}

 

 

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Developer
sorout2009
Posts: 104
Registered: ‎08-23-2012
My Device: Blackberry Z10
My Carrier: TATA DOCOMO

Re: How to check whether internet is enbled or disabled?

Hi 

bool available = false;
QNetworkConfigurationManager netMgr;
QList<QNetworkConfiguration> mNetList = netMgr.allConfigurations(QNetworkConfiguration::Active);
if (mNetList.count() > 0) {
if (netMgr.isOnline()) {
available = true;
qDebug()<< "internet available";
}
}
qDebug()<< "internet availablity :"<<available;

 

I tried that code but every time I got false. Please suggest.

Dharmender Singh
Please use plain text.
Contributor
vistate
Posts: 28
Registered: ‎06-17-2013
My Device: Z10
My Carrier: Bell

Re: How to check whether internet is enbled or disabled?

Do you use anything that attempts to check for internet on your main.qml or what ever you use for the front page?

 

For instance - mine tries to load an xml remotely for a listview - and i do an onerror dialog to say Please check your internet connection.

 

its a very simplistic work arround.

 

Please use plain text.
Contributor
luchoc_29
Posts: 15
Registered: ‎08-09-2013
My Device: Developer
My Carrier: -

Re: How to check whether internet is enbled or disabled?

Try with this, this code worked to me... !

with this you can know if there some network enable to connect to internet ...!!! 

 

bool app::isNetworkAvailable()

{

   QNetworkConfigurationManager netMgr; QList<QNetworkConfiguration> mNetList = netMgr.allConfigurations(  QNetworkConfiguration::Active);

 

if (mNetList.count() > 0)

{

  if (netMgr.isOnline())

  {

       return true;

   }

   else

   {

       return false;

    }

}

else

{

     return false;

}

 

}

 

 

Enjoy it !!!!   :smileywink:

Please use plain text.
Developer
lalthomas
Posts: 21
Registered: ‎05-16-2013
My Device: Developer
My Carrier: Developer

Re: How to check whether internet is enbled or disabled?

You will get correct results only when you use BPS services

Please use plain text.