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
Developer
Posts: 655
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers
Accepted Solution

Connected to Wifi?

I usually use the following piece of code to see if a wifi connection is available.
   if(WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
        {
          
            connectionString = ";interface=wifi";
        }
I was at a hotspot area and saw that the wifi symbol was white as if I had a connection, but I had never logged into the hotspot.   In my test app the above code passed as if I was connected to wifi but the app didn't work when it tried to make HTTP connections (since I hadn't logged into the hotspot).  
Does this make sense and if so what could I have done to know if the user was really connected (ie: make a dummy connection to see if it fails)?
Thanks in advance for any ideas.

Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE
My Carrier: Vodafone NL

Re: Connected to Wifi?

Some WiFi points have public access but requires some login (pay) operation before getting the internet access (but you already know this). Unfortunately I don't know any method for sure except successful getting data from internet.

You can try to get small response from quick servers (google for example). And continue network discovery in case of failure. But even after success with small requests I'm not sure in 100% that my request will pass.

 

Thanks,

Eugen

Developer
Posts: 655
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Connected to Wifi?

Thanks for the advice. I was thinking about trying a quick response as well to insure full internet access. I'll try that and see how it goes.

Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 105
Registered: ‎06-23-2010
My Device: 9000
My Carrier: vodaphone

Re: Connected to Wifi?

Richard,

I do exactly the same thing. I make a quick call to confirm the connectivity actually works...

 

-matt

Press Kudos if this helped - ;-)
Developer
Posts: 655
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Connected to Wifi?

Thanks Richard, do you think doing this is accurate enough :
rc = c.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}

Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 105
Registered: ‎06-23-2010
My Device: 9000
My Carrier: vodaphone

Re: Connected to Wifi?

I guess one would have to call a familiar URL that returns 'something'. Just seeing if the connection is open, probably won't work as there is a gateway authentication webpage that will load and return a valid value. What you are trying to check is that the route is available...

 

I wish a 'ping' would work, that would be the least intensive...

 

 

 

-matt

Press Kudos if this helped - ;-)
Developer
Posts: 655
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Connected to Wifi?

I understand. Thanks.

Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing