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
javec
Posts: 445
Registered: ‎07-15-2008
My Device: Not Specified
Accepted Solution

Radio On / Off

Hello,
so I found out that since API Version 4.x it is possible to activate/deactive the radio of the device. That's how I do it:


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") ;

}

 




Turning off the radio works, but turning it on again does not work. I think it's because of the Radio.activateWafs(i)..
can someone show me how to switch on the radio?
If your question was answered, please accept it as a sollution and / or give Kudos ;-)
______________________________
Use the Search Field first! Maybe the question you want to ask already exists!
Please use plain text.
Administrator
MSohm
Posts: 14,421
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Radio On / Off

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).

 

Returns:
True if the request was successful and false if not. If the request was successful, it does not guarantee that the specified WAFs were activated.

 


 

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?

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
Please use plain text.
Developer
javec
Posts: 445
Registered: ‎07-15-2008
My Device: Not Specified

Re: Radio On / Off

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 

If your question was answered, please accept it as a sollution and / or give Kudos ;-)
______________________________
Use the Search Field first! Maybe the question you want to ask already exists!
Please use plain text.
Administrator
MSohm
Posts: 14,421
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Radio On / Off

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.

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
Please use plain text.
Developer
javec
Posts: 445
Registered: ‎07-15-2008
My Device: Not Specified

Re: Radio On / Off

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? 

If your question was answered, please accept it as a sollution and / or give Kudos ;-)
______________________________
Use the Search Field first! Maybe the question you want to ask already exists!
Please use plain text.
Administrator
MSohm
Posts: 14,421
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Radio On / Off

Use the 3GPP Wireless Access Family for switching the GSM/GPRS/EDGE network.
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
Please use plain text.
Developer
javec
Posts: 445
Registered: ‎07-15-2008
My Device: Not Specified

Re: Radio On / Off

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 }

 

 

 

If your question was answered, please accept it as a sollution and / or give Kudos ;-)
______________________________
Use the Search Field first! Maybe the question you want to ask already exists!
Please use plain text.