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
markww
Posts: 70
Registered: ‎08-18-2008
My Device: Not Specified

Checking if phone has signal?

Hi,

 

What's the right way to check if the user has data service at any given moment?

 

I'd like to stop trying to make web service calls if i find the user has no signal (ie. went into a subway or a tunnel).I see th:

 

    net.rim.device.api.system.RadioInfo

 

has some information which may be useful for this, is there an accepted way of doing it?

 

Thanks

Please use plain text.
Developer
simon_hain
Posts: 15,791
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Checking if phone has signal?

I use CoverageInfo.isOutOfCoverage() and RadioInfo.isDataServiceSuspended()
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Checking if phone has signal?

Try the getState() and getSignalLevel() methods of RadioInfo.

 

Please use plain text.
Developer
markww
Posts: 70
Registered: ‎08-18-2008
My Device: Not Specified

Re: Checking if phone has signal?

Ok thanks for the info, I am running on the JDE 8130 emulator right now, printed out some of the values for a look. I get the same values when running the MDS server as for when it is off:

 

CoverageInfo.isOutOfCoverage():......................false
CoverageInfo.isCoverageSufficient(COVERAGE_CARRIER):.true
CoverageInfo.isCoverageSufficient(COVERAGE_MDS):.....false
RadioInfo.isDataServiceSuspended():..................false
RadioInfo.isDataServiceOperational():................true
RadioInfo.getSignalLevel():..........................-40
RadioInfo.getState():................................1

 

is it going to be possible to simulate through the emulator? If not I guess I'll have to put it on an actual device to see what happens.

 

So Simon, you say to check:

 

    return CoverageInfo.isOutOfCoverage() &&

             RadioInfo.isDataServiceSuspended();

 

Rex, you recommend getState() and getSignalLevel(), but what values should I expect from them to tell if I have no data service?

 

Lastly, is it an expensive operation to check these stats? If I'm doing it every 30 seconds, am I going to kill the user's battery?

 

Thanks

Please use plain text.
Administrator
MSohm
Posts: 14,226
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Checking if phone has signal?

The BlackBerry Simulator is not aware of whether or not the MDS Simulator is running, so this should be tested on an real device.

 

I recommend looking at the sample code found here:

 

How To - Determine when to route data 
Article Number: DB-00485

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/How_To_...

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
markww
Posts: 70
Registered: ‎08-18-2008
My Device: Not Specified

Re: Checking if phone has signal?

Thanks again Mark. Where does "serviceUID" come from though?:

 

   if( ServiceBook.getSB().getRecordByUidAndCid( serviceUID, "IPPP" ) == null ) {
      // There is no service book
      return false;
   }
   if( ServiceRouting.getInstance().isSerialBypassActive (serviceUID) ) {
      // Serial bypass is active
      return true;
   }

 

Thanks

Please use plain text.
Administrator
MSohm
Posts: 14,226
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Checking if phone has signal?

This is the UID for the ServiceRecord in the ServiceBook you are interested it.  You can view it by going to Options, Advanced Options, Service Book and viewing a service record.  You can access it programmatically using the ServiceRecord.getUid method.

 

The example assumes you want to check for a particular service record, which may or may not be the case.

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.