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

Web and WebWorks Development

Reply
Highlighted
Developer
Posts: 161
Registered: ‎02-08-2012
My Device: PlayBook
My Carrier: None yet
Accepted Solution

how to detect internet connectivity?

How does one detect wether there is a connection available?

 

Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900
My Carrier: Rogers

Re: how to detect internet connectivity?

Have you tried hasDataCoverage? Should do what you need.

https://bdsc.webapps.blackberry.com/html5/apis/blackberry.system.html#.hasDataCoverage

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
Developer
Posts: 161
Registered: ‎02-08-2012
My Device: PlayBook
My Carrier: None yet

Re: how to detect internet connectivity?

hmm.. so, no way to get an event when the connection drops?
Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900
My Carrier: Rogers

Re: how to detect internet connectivity?

[ Edited ]

Have a look at onCoverageChange, I believe you can attach an listener to it, although I haven't used it yet (found it doing research for an in-progress app) https://bdsc.webapps.blackberry.com/html5/apis/blackberry.system.event.html#.onCoverageChange

 

edit: double checked you are infact registering a listener with a callback when coverage changes, so that should do exactly what you need (I think?)

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
Developer
Posts: 161
Registered: ‎02-08-2012
My Device: PlayBook
My Carrier: None yet

Re: how to detect internet connectivity?

ya, i saw that, but it's not available in playbook Smiley Indifferent
Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900
My Carrier: Rogers

Re: how to detect internet connectivity?

I don't know how reliable window.navigator.onLine is in WebWorks but you could try something like:

 

window.addEventListener("offline",function(e){ alert("offline");},false); window.addEventListener("online",function(e){ alert("online");},false);

Then trigger whatever you want to do when the status changes.

 

references (or further reading):

https://developer.mozilla.org/en/DOM/window.navigator.onLine

http://www.html5rocks.com/en/mobile/workingoffthegrid/

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
Developer
Posts: 161
Registered: ‎02-08-2012
My Device: PlayBook
My Carrier: None yet

Re: how to detect internet connectivity?

navigator.onLine is completely broken in all browsers -- it requires manual setting to "work offline mode". I tested every device I have available on it last night - PB, webOS, Android, all the desktop browsers. Not a one of them gets it right.

Regular Contributor
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: how to detect internet connectivity?

Is there anyway to check what kind of connection it has ? e.g. 3g , cdma, wifi , blue tethering, bridge?
Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900
My Carrier: Rogers

Re: how to detect internet connectivity?

I don't know how specific it gets but check blackberry.network if you are on developing for phones (https://bdsc.webapps.blackberry.com/html5/apis/blackberry.html)

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
Regular Contributor
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: how to detect internet connectivity?

Thanks for your help, yes this works fine on mobiles but not the playbook, are you aware of any playbook ways of doing this?