Hi I am working with android webview application.I uses my the url succesfully in my app and it works only if internet connection available .But I want to show some messages
Call this method before opening the webView if this method returns true that means the internet connection is avialable and you can process to the webview otherwise show some Toast or you can show Dialog if this method returns false.
Edit
Use this code like in your Main Activity as like this
if(isNetworkStatusAvialable (getApplicationContext())) {
Toast.makeText(getApplicationContext(), "internet avialable", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "internet is not avialable", Toast.LENGTH_SHORT).show();
}
Method
public static boolean isNetworkStatusAvialable (Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null)
{
NetworkInfo netInfos = connectivityManager.getActiveNetworkInfo();
if(netInfos != null)
if(netInfos.isConnected())
return true;
}
return false;
}