How to check the Internet Connectivity status of My Android App

How to check the Internet Connectivity status of My Android App in phonegap ?

I have read through the phonegap documentation but I dont understand it.

Please I will greatly appreciate if Someone can provide me with a Sample script of how to do this.


1 Like

You can just check navigator.onLine

This ain’t working! it will always return ‘true’ no matter what!

Create a NEW method call isonline()

Inside app.js there is a varialbel called online. You just have to do the following: if you are with Internet it will be true, otherwise it will be false. There is a question in this function is that if you are connected to a Wi-Fi network and in that network there is no access to the Internet, it will always return a value of true.

Lke this:
IsOnline: function()

This is more like a general js issue, rather than F7, but I use this method. You can translate it into F7 easily.

function checkCon()
    url: "/anysite.html",
    cache: false,
    type: "GET",
   crossDomain : true,
   success: function(response) {
		   document.getElementById("logStatus").innerHTML= "";
    error: function(xhr) {
	    document.getElementById("logStatus").innerHTML    = "<span style='color:red' class='warning'>No connection. <a href='login.html'>Refresh</a> page.</span>";


That’s true, because the best way to check connectivity is to use this cordova plugin.
Using navigator.onLine won’t work as you would like.