07-17-2008 02:50 AM
int i = RadioInfo.getActiveWAFs();
int iState = RadioInfo.getState();
if (iState==0){//on
Radio.activateWAFs(i);
Dialog.alert("Radio switched on") ;
}
if (iState==1){//off
Radio.deactivateWAFs(i);
Dialog.alert("Radio switched off") ;
}
Solved! Go to Solution.
07-17-2008 09:33 AM
From the JavaDocs for Radio.activateWAFs:
This method requests that the radios that belong to the provided Wireless Access Families (WAFs) be powered on. A request will not be successful if the BlackBerry device is in the process of an Upgrade over the wireless network, or if the CryptoBlock or USBPasswordRedirectManager does not allow the radio to be turned on.
If the request is successful, and all the specified WAF(s) are supported, the activateWAFs method activates the specified WAF(s). To determine if a WAF is supported, call RadioInfo.areWAFsSupported(int).
Is the method returning true or false for you? What BlackBerry model and handheld software version are you testing with? You can find this under Options, About on the BlackBerry. Does it fail occasionally or does it never work?
07-17-2008 10:44 AM
yes, this:
Radio.activateWAFs(i);
returns true. but it does not switch on the radio. tried it on the simulator: 8300, v4.5.0.44
07-17-2008 11:15 AM
In your code sample, you are resetting i each time. If there is no radio on, getActiveWAFs is going to return 0. So if you use this value in the activateWAFs call, you are basically telling the system to turn on none of the radios.
Instead, you should pass in the combination of RadioInfo.WAF*** families you wish to turn on.
07-17-2008 11:29 AM
Oh I see,
but the supported WAFs are:
static int WAF_3GPP 3GPP Wireless Access Family. static int WAF_CDMA CDMA Wireless Access Family. static int WAF_IDEN iDEN Wireless Access Family. static int WAF_WLAN WLAN Wireless Access Family.
and what if I want to switch on GSM? Does it make a difference between switching on CDMA or GSM?
07-17-2008 11:51 AM
07-17-2008 04:28 PM
OK so to bring this post to a solution and maybe someone else needs it again, here is how to switch the radio on and off:
int i = RadioInfo.getActiveWAFs(); int iState = RadioInfo.getState(); if (iState==0){ Radio.activateWAFs(RadioInfo.WAF_3GPP); //for GSM Radio.activateWAFs(RadioInfo.WAF_CDMA); //for CDMA //switches the network on } if (iState==1){ Radio.deactivateWAFs(i); //switches the network off }