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

Java Development

Reply
Contributor
Posts: 37
Registered: ‎01-24-2011
My Device: Not Specified

How to check if internet is available over wifi ?

Hi,

 

In my application I want to check if device is connected to a wifi network and then I want to check if internet connection is available by the wifi network.

 

RIM API provides tools to detect if device is connected to wifi network.

Does anybody know if RIM API provides a way to check if internet connection is available without doing a ping manually ?

 

Thanks in advance.

Trusted Contributor
Posts: 151
Registered: ‎06-17-2010
My Device: Curve 8900
My Carrier: Vodafone

Re: How to check if internet is available over wifi ?

Hi dtea,

 

this code can help you to check if Wifi is available for your device or not..

 

 


if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED && RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN))

{

Dialog.alert("wifi connection available.")

}else {
Dialog.alert("wifi connection not found!");
}

use this code to check wifi connection.. and Enjoy... Smiley Very Happy

 


 

Don't Say thanks, press the kudos button  on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Contributor
Posts: 37
Registered: ‎01-24-2011
My Device: Not Specified

Re: How to check if internet is available over wifi ?

Ok thank you. I am going to try this code.

If my BB is connected to hotspot browser but I am not logged in I cannot connect to the internet.

Do you know if your code will return "wifi not available" in this case ?

Trusted Contributor
Posts: 151
Registered: ‎06-17-2010
My Device: Curve 8900
My Carrier: Vodafone

Re: How to check if internet is available over wifi ?

Hey dtea,

 

yes dude. em definately sure that it works perfectly, cause i have also used this code in my application and it is working fine for me....

 

Good Luck to you ....Smiley Tongue

 


Don't Say thanks, press the kudos button  on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

 

Contributor
Posts: 37
Registered: ‎01-24-2011
My Device: Not Specified

Re: How to check if internet is available over wifi ?

Thank you albert.

I suppose this code checks if internet is avalaible :

WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED

WLANInfo is available in 4.3 and later. Do you know if API version 4.2.1 provides tools to do the same thing ?

Developer
Posts: 105
Registered: ‎06-23-2010
My Device: 9000
My Carrier: vodaphone

Re: How to check if internet is available over wifi ?

All,

there is another dicussion going on around a similar topic. Just because WIFI is available doesn't actually mean it can be used. The problem arises when the device is connected but needs credentials. The conclusion was that a call needs to be made to insure that one can actually route to the desired server.

 

 

-matt

Press Kudos if this helped - ;-)
Contributor
Posts: 37
Registered: ‎01-24-2011
My Device: Not Specified

Re: How to check if internet is available over wifi ?

Hi mtatro,

When you say "The conclusion was that a call needs to be made to insure that one can actually route to the desired server". That means doing a ping to the desired server ?

Highlighted
Developer
Posts: 105
Registered: ‎06-23-2010
My Device: 9000
My Carrier: vodaphone

Re: How to check if internet is available over wifi ?

Somehow you need to make sure that you can actually reaach the destinattion server...a ping may work (problem is that ping may be turned off on the server) or making some kind off call to check the connection.

 

-matt

Press Kudos if this helped - ;-)