How to check if internet connection is available on Android or iOS

Recently I spent several hours looking for a script to In this video check if internet connection is available on Android application. I have found a lot of bad scripts and I have created my own script. It's very simple and works very well.

In this tutorial I will show my way to check if internet connection is present in Android, Windows Phone, iOS, etc.

My way works and it is very simple.

If you create an application with Phonegap, just add this code

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script><script language="javascript">// <![CDATA[
var u = 1;
if(typeof jQuery != 'undefined') {
u = 2;
}
if(u == 1)
{
alert("No Internet Connection");
do something!
}
// ]]></script>

in all your pages.

 

I hope this will be helpful for you!









Leave a Comment