views:

24

answers:

1

I'm working with the NetworkUtils.java class created by Sameer Nafdey in his blog post regarding accuiring a network connection within a Blackberry Application. However I recently noticed that my application was using the cell network even when a WiFi connection was available. I realized this was the case when we tested the application on a Torch with no SIM card and the app failed. After some debugging I found that:

if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED){...}

was returning false despite the fact that the WiFi network was setup correctly (I was able to use web browser to visit Google). We had to return the Torch but while debugging the app in the simulator I noticed that if WiFi was on but the Data Network was turned off then this call would work correctly. However I would then get an exception (java.io.ioexception: Radio is off) when executing this block:

httpConnector = (HttpConnection)Connector.open(URL);
httpConnector.setRequestMethod(HttpConnection.GET);
httpConnector.setRequestProperty("Content-Type", "text/plain; charset=UTF-8");
in = httpConnector.openInputStream();

I've seen a lot of issues related to the Torch's WiFi connectivity problems but I'm currently concerned that this behavior may also be affecting other models. Anyone seen anything like this or have an idea of how to fix it?

A: 

You could try:

if( RadioInfo.areWAFsSupported( RadioInfo.WAF_WLAN )
    && 
    ( RadioInfo.getActiveWAFs() & RadioInfo.WAF_WLAN ) != 0
    && 
    CoverageInfo.isCoverageSufficient( 1 , RadioInfo.WAF_WLAN, false) ) 
{ ... }

It's been working so far, on Blackberry OS 6.0 (Torch 9800). Tested on device and sim.

eSniff
ohh yea, BTW I did have issues with OS 6 adding a new service record which broke my BIS connections.
eSniff