Apply the below Code,
WebView.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { WebView.loadUrl("file:///android_asset/myerrorpage.html"); } });
Apply the below Code,
WebView.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { WebView.loadUrl("file:///android_asset/myerrorpage.html"); } });
private boolean isNetworkConnected()
{
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null)
{
//There are no active networks. return false;
}
else
{
return true;
}
}
The above function will return true only if the device has internet connection otherwise false.
manifest file permissions,
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />