I am using
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
PtrCLog.d("WebFragment", "onReceivedError: " + "");
}
This method has not been rolled back. After checking, it is said that API23 is required. . Does anyone know of any other ways to get 404?
Run an AsyncTask in onPageStarted, use an Http client such as OkHttpClient in the AsyncTask to make a request for the URL that needs to be accessed, and obtain the code
Here, Webview and OkHttpClient are actually loaded, but the WebView is hidden when the AsyncTask is running. If it is confirmed to be 200, it will be displayed. If it is not 200, the page that failed to load will be displayed.