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
ianstrain
Posts: 62
Registered: ‎07-15-2008
My Device: Not Specified

How do you detect if the device is using wifi?

I have read that if there is an active wifi connection enabled on the device that the OS will automatically send data over wifi when using http in an application and you don't need to append ";deviceside=true;interface=wifi" to the url.

Is that the case?

If so, is there then a way to detect that the data is being sent using wifi? My application needs to send the connection type along with the request to the server.

 

Thanks.

BlackBerry Development Advisor
MSohm
Posts: 14,752
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: How do you detect if the device is using wifi?

Assuming the connection can be made over Wi-Fi this is true.  There is no way to query the route your connection has been made over.  You can control it through the user if the deviceside and interface parameters.

 

Your application can listen for when the BlackBerry has connected or disconnected to a Wi-Fi network by using the WLANConnectionListener.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Warlock
Posts: 8
Registered: ‎09-25-2008
My Device: Not Specified

Re: How do you detect if the device is using wifi?

The way I do it is to have four or five different connection strings and try them all one at a time until one of them works - I try connecting with no strings aside from the URL, then rotate (if an exception is raised) onto the WiFi strings, BIS etc...
Developer
ianstrain
Posts: 62
Registered: ‎07-15-2008
My Device: Not Specified

Re: How do you detect if the device is using wifi?

So it is automatic. What happens if the user either takes out the SIM card or turns the Mobile Network off? Will it still connect over wi-fi? I have tried this and appears that it won't connect using wi-fi. Connector.open throws an IOException. This raises an issue with the user. If you say the application will connect automatically using available wi-fi, the user might be inclined to test this by turning off mobile network at which point the application will fail to connect and will give the user the impression that the application actually does not use wi-fi at all.

 

your views?

New Developer
Warlock
Posts: 8
Registered: ‎09-25-2008
My Device: Not Specified

Re: How do you detect if the device is using wifi?

Interesting...  it might give the user the impression there is no WiFi on the app - but the reality will just be there is no current access to the interwebs...  So if you throw an error message up like "Cannot connect to interwebs, check your connection" or something you should have your bases covered.  I think that's what I am doing - if I can't connect in one of five ways I spit out a Connection Error message with the added message "I hate you for turning off my WiFi.  I'm lonely." :smileyhappy: