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
Posts: 37
Registered: ‎05-27-2010
My Device: 9700 Storm

In Code, How to Check Whether or Not Device is "Offline"?

Hi,

 

I'm doing a Web Service based application for Blackberry handsets. I have to check frequently whether the device is in coverage area or not. If there is lack of signals, I have to update the offline database and whenever the handset become online, I have to sync back to the web server. My doubt is, is there any method in Blackberry API which checks whether the device is in coverage area or not?

 

Please help me, Thanks in Advance Smiley Tongue

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Developer
Posts: 16,932
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: In Code, How to Check Whether or Not Device is "Offline"?

use a coveragelistener for this.

to do a check for the current time you can use coverageinfo

----------------------------------------------------------
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
Developer
Posts: 37
Registered: ‎05-27-2010
My Device: 9700 Storm

Re: In Code, How to Check Whether or Not Device is "Offline"?

I used CoverageStatusListener and CoverageInfo as given in the following thread.

 

http://supportforums.blackberry.com/t5/Java-Development/test-blackberry-BES-connection/m-p/227189

 

But, it's not working. Right now, I'm doing in Simulator and I need a method which returns a value if MDS is started and another value otherwise. CoverageInfo.isCoverageSufficient() is not varying if I close the MDS and start again. Please tell me a way to know whether or not MDS is started.

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: In Code, How to Check Whether or Not Device is "Offline"?

I presume by this you expect the BlackBerry Simualktor to know if the NMDS Simulator is running and/or the BlackBerry device to know if the MDS Service is running or not. 

 

AFAIK, it is not possible to know this - though of course you can try it and see if it fails or not.  In fact with MDS, it usually times out if MDS is not there. 

Developer
Posts: 37
Registered: ‎05-27-2010
My Device: 9700 Storm

Re: In Code, How to Check Whether or Not Device is "Offline"?

Hi,

 

I'm not using MDS now, added ";deviceside=true" with the URL. I'm testing this in Simulator. I have implemented CoverageStatusListener and coverageStatusChanged method. But this method is never called. So, in fieldChanged method I gave like this

 

if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)) 
{ 
    Dialog.inform("You Are In Coverage Area"); 
}
else 
{ 
    UiApplication.getUiApplication().invokeLater(new Runnable() 
    { 
	public void run() 
	{ 
	    Dialog.inform("You are out of signal coverage area"); 
	} 
    }); 
} 

But even if I disable the Local Area Connection, it shows "You are in Coverage Area". Instead of isCoverageSufficient() method I used isOutOfCoverage(), but the same thing happens. If MDS is started, we can assume this from the return value of HttpConnection.getResponseCode(). But, if MDS is not used and LAN Connection is disabled,  it's showing DNSException after the Connector.open(url) statement. Is there any way to find out whether Coverage is available or not if MDS is not started with Simulator?

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Highlighted
Developer
Posts: 207
Registered: ‎09-10-2010
My Device: Not Specified

Re: In Code, How to Check Whether or Not Device is "Offline"?

If i understood you correctly,  you dont have to disable your system connection. To simulate out of coverage and low signal cases, 

 

In simulator toolbar, go to Simulate > Networking Properties. Here you can change signal strength. 

 

To detect out of coverage, I usually turn off radio signal from device simulator.  Go to Manage Connections, uncheck  "Mobile Network".