06-20-2012 06:00 AM
06-21-2012 12:01 AM
06-21-2012 01:40 AM
Yeah, blackberry.system.hasDataCoverage will just tell you, if that PlayBook is connected to a WiFi and not if that WiFi has internet access.
Why don't you just try to access your desired resource and set a fast request timeout with user friendly error handling (e.g. ajax load animation and after 5 seconds a "Sorry, you need to be connected to the Internet" message)?
06-21-2012 05:35 AM
06-21-2012 05:47 AM
It depends on your app and the data to be transmitted.
Here's what works for me (app with local DB and a webservice that supplies weather information, marketplace items, custom map entries, ...):
Upon app startup I usually check weather the device has any kind of connection (WebWorks/PhoneGap SDK). If the device has no connection at all, I'll skip all connection efforts (for a defined timeframe).
If there is a connection, I send a small request (init) to my webservice, followed by a tiny reply (just hash tags which signalize if and which parts of my app's offline database need to be updated). This call even takes <2 secs with a 2G connection. So a timeout of this request after 5 or 10 seconds clearly states: no internet is available at the moment!
If the app already has preloaded data available for offline use, I'll display that and try the init call again a couple of minutes later. If not, I show a warning "Internet connection required.".