//Connection Detector is used to to check the connectivity
ConnectionDetector cd;
cd = new ConnectionDetector(getApplicationContext());
Boolean isInternetPresent = cd.isConnectingToInternet();
// check for Internet status
if (isInternetPresent) {
// Internet Connection is Present
// make HTTP requests
//put your code if internet is present
} else {
// Internet connection is not present
cd = new ConnectionDetector(getApplicationContext());
Boolean isInternetPresent = cd.isConnectingToInternet();
// check for Internet status
if (isInternetPresent) {
// Internet Connection is Present
// make HTTP requests
//put your code if internet is present
} else {
// Internet connection is not present
/*putting a dialog box for else is a good practise */
/* click below link for alert dialog box */
}
}
For alert dialog box click below link
http://www.testedcodes.net/2015/07/alert-dialog-box-1.html
No comments:
Post a Comment