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
New Contributor
Posts: 6
Registered: ‎06-21-2010
My Device: BlackBerry Bold 9700
My Carrier: O2

RadioInfo getNetworkType always returns GPRS

Hi, 

 

I want to try and detect whether the device has an available 3G or Wifi connection from within a thread, so have used the RadioInfo API in the following way:

 

 

if ( RadioInfo.getNetworkType() == RadioInfo.NETWORK_802_11 || RadioInfo.getNetworkType() == RadioInfo.NETWORK_UMTS )
{
    //do something
}
else
{
    //do something else
}

 

 

This doesn't seem to be working, and I have used the debugger to find out that RadioInfo.getNetworkType() is always returning the value '3', which corresponds to NETWORK_GPRS. I have tried different combinations of network types in the Network Properties menu of the simulator, and the network symbols change accordingly in the banner on the homescreen, but still I get the value '3' for the network type.

 

I'm running the 9700 simulator with the 5.0 APIs and using the MDS simulator for connectivity.

 

Any ideas why this isn't producing the expected results would be much appreciated.

BlackBerry Development Advisor
Posts: 15,752
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: RadioInfo getNetworkType always returns GPRS

What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.  Are you seeing the same behaviour on a real BlackBerry Smartphone? 

 

The RadioInfo class is best tested on a real BlackBerry Smartphone.  Testing it using the simulator is not always accurate due to the way the network is simulated.

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
Highlighted
Contributor
Posts: 27
Registered: ‎05-28-2010
My Device: 9000
My Carrier: Airtel

Re: RadioInfo getNetworkType always returns GPRS

Hi,

 

Better to use code given below to check for the WiFI network.

 

if(RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN){

 

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

 

                          //then append "interface=wifi" with your connection string.

           }

 

}