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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
alexpoke
Posts: 45
Registered: ‎09-06-2011
My Carrier: Vodafone
Accepted Solution

how to detect if data service is off?

Hi,

 

Since the device cannot connect to the Internet fi Data service is set to OFF, not even with WiFI, I need to prompt an Internet Unavailable message when data services are off.

 

can anyone please tell me how can i do this? 

 

I have been trying several options, but none worked.

 

The best advice i got so far is to use a HttpConnection ong google.com. :smileyvery-happy: I think it works, but i would like something more...elegant

 

Regards,

Alex

Please use plain text.
Developer
simon_hain
Posts: 13,817
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: how to detect if data service is off?

http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/system/CoverageInfo.html#isCov...
----------------------------------------------------------
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
rabiray
Posts: 141
Registered: ‎07-13-2011
My Carrier: Vodafone

Re: how to detect if data service is off?

Have a look into the RadioInfo class

 

isDataServiceOperational

 

method may help.

Please use plain text.
Developer
pankajace12
Posts: 188
Registered: ‎04-30-2011
My Carrier: Airtel

Re: how to detect if data service is off?

Hi alexpoke

if(CoverageInfo.getCoverageStatus()==CoverageInfo.COVERAGE_NONE)
{
Dialog.alert("No Connection: ");
}
else
{
Dialog.alert("Connection: ");
}

Thanks
Please use plain text.
Developer
lakshman9687
Posts: 226
Registered: ‎07-22-2011
My Carrier: AirTel

Re: how to detect if data service is off?

[ Edited ]

H,

You can check like this also,

 

 if(!checkCoverage() )

{

    Dialog.alert("No Connection.");

}

 

Regards,

Lakshman

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

Please use plain text.
Contributor
alexpoke
Posts: 45
Registered: ‎09-06-2011
My Carrier: Vodafone

Re: how to detect if data service is off?

Hi guys,

 

Thank you for your replys,

 

Unfortunately none of the solutions  you suggested worked on the device. However, lakshman9687's approach works well on the Simulator.

I am using a Torch 9860 with 3G and WiFi on and Data Services Off to test this.

 

Apparently the browser and the App World app seem to notice the missing of the service, so I guess there must be a way..

 

Thanks again for your feedback.

 

CHeers, Alex

Please use plain text.
Developer
lakshman9687
Posts: 226
Registered: ‎07-22-2011
My Carrier: AirTel

Re: how to detect if data service is off?

Hi,

 

If u found the solution then mark as accept and close the thread other wise this thread is showing open...

 

Regards,

Lakshman K

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

Please use plain text.
Contributor
alexpoke
Posts: 45
Registered: ‎09-06-2011
My Carrier: Vodafone

Re: how to detect if data service is off?

"Unfortunately none of the solutions you suggested worked on the device."

I assume there must e a solution, but I haven't found it yet
Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: how to detect if data service is off?

"Unfortunately none of the solutions  you suggested worked on the device"

 

You mean that they suggested there was data service when there was not or the other way round?  Can you give us the results you saw and the device OS level you tested on?

Please use plain text.
Contributor
alexpoke
Posts: 45
Registered: ‎09-06-2011
My Carrier: Vodafone

Re: how to detect if data service is off?

Hi,

 

Apparently I was wrong. I don't really know how I tested that and got misleading results, but now I am testing it again on the same device and it appears to be working just fine.

 

Sorry for this.

 

To summarize here is the code that works: 

boolean coverage_status = false;
		        
if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS)) {
    coverage_status = true;
} else if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_BIS_B)) {
    coverage_status = true;
} else if ((RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN) && WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)) {
    coverage_status = true;
} else if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT)) {
    coverage_status = true;
}
		        
return coverage_status;

 Thanks again,  lakshman9687, for the solution.

 

Cheers,

Alex

 

 

Please use plain text.