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
Highlighted
Contributor
Posts: 45
Registered: ‎09-06-2011
My Device: 9800
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. Smiley Very Happy I think it works, but i would like something more...elegant

 

Regards,

Alex

Developer
Posts: 16,984
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
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
Developer
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold
My Carrier: Vodafone

Re: how to detect if data service is off?

Have a look into the RadioInfo class

 

isDataServiceOperational

 

method may help.

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
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
Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
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.

Contributor
Posts: 45
Registered: ‎09-06-2011
My Device: 9800
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

Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
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.

Contributor
Posts: 45
Registered: ‎09-06-2011
My Device: 9800
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
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

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?

Contributor
Posts: 45
Registered: ‎09-06-2011
My Device: 9800
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