I am doing a application which uses the Internet Connection through out the application. If the internet connection is lost while using the application, the application is forcibly closing. To avoid this, if internet is not available i want to show a Alert message. How can i do this. At the time of Login i am checking the connectivity using the below code. But how can i do this for whole application in background.
private boolean haveInternet(){
NetworkInfo info = ((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (info==null || !info.isConnected()) {
return false;
}
if (info.isRoaming()) {
// here is the roaming option you can change it if you want to disable internet while roaming, just return false
return true;
}
return true;
}
Thank you..