I am using phonegap for my app. My app is basicaly for RSS_FEED from one website.
but my requirement is when internet is not there application should alert
-offline
.
when application run on online all data stored into database.
and when internet is not there that time data fetched from DB so my problem is only that application shows me online every time while using of navigator.onLine
.
if(navigator.onLine) {
alert("check online");
loadScript("http://www.google.com/jsapi",msgOnFn)
loadScript("js/googleapi.js", msgOnFn);
} else {
loadScript("js/db.js",msgOffFn);
}
I tried THIS ALSO In this it shows none or wifi everytime. I am not getting why this happening.
in web browser,It is working fine. :)
please follow the phonegap documentation.
You could also change the given function to return true or false:
function checkConnection() {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = false;
states[Connection.ETHERNET] = true;
states[Connection.WIFI] = true;
states[Connection.CELL_2G] = true;
states[Connection.CELL_3G] = true;
states[Connection.CELL_4G] = true;
states[Connection.CELL] = true;
states[Connection.NONE] = false;
if (states[networkState]) {
return true;
} else {
return false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With