Skip to content

Instantly share code, notes, and snippets.

@Ansh1234
Created April 26, 2017 14:38
Show Gist options
  • Save Ansh1234/1098cb5e3a6df950cd012e854c01b237 to your computer and use it in GitHub Desktop.
Save Ansh1234/1098cb5e3a6df950cd012e854c01b237 to your computer and use it in GitHub Desktop.
public class CustomWebViewClient extends WebViewClient {
private String TAG = "CustomWebViewClient";
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
Log.d(TAG, "The webView with the following url " + url + " has started loading");
}
@Override
public final void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.d(TAG, "The webView with the following url " + url + " has finished loading");
}
@SuppressWarnings("deprecation")
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
Log.d(TAG, "The webView with the following url " + failingUrl +
" failed with the following errorCode " +
"" + errorCode);
}
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
Log.d(TAG, "The webView with the following url " + request.getUrl().toString() +
" failed with the following errorCode " +
"" + error.getDescription());
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onReceivedHttpError(
WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
super.onReceivedHttpError(view, request, errorResponse);
Log.d(TAG, "The webView with the following url " + request.getUrl().toString() +
" failed with the following errorCode " +
"" + errorResponse.getStatusCode());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment