callback/callback-android — Issue #17: Connection reported as Connection.NONE
Author: pamelafox
Created: 2011-11-04 22:08:52+00:00
State: open

To be pursuant with Apple guidelines, I recently put checks into my code to detect offline/online status for my apps and alert accordingly. I used this function to detect:

function isOnline() {
// Presume online unless PhoneGap or HTML5 tell us otherwise.
if (navigator.network && navigator.network.connection.type == Connection.NONE) {
return false;
}
if (navigator.onLine && typeof navigator.onLine == 'boolean' && navigator.onLine === false) {
return false;
}
return true;
}

This works as expected for me, but for one of my users (on an Android 2.3), it reports Connection.NONE even when they have perfect reception. So I'm no longer using the network.connection status.

Maybe it doesn't work for some carriers? Or it shouldn't be relied upon for disabling functionality?