Easy Tutorial
❮ Sql Join Image Explain Es6 Reflect Proxy ❯

7.5.6 Handling WebView Error Code Information

Category Android Basic Beginner Tutorial

Introduction:

>

Hey, if your company develops mobile apps for the HTML5 platform, which means displaying web pages through WebView, if you encounter a page that doesn't exist or other errors that return status codes like 404, 401, 403, 30X, etc., showing the default error page from WebView might not be very user-friendly. We can override the onReceivedError() method of WebViewClient to achieve the desired effect. There are generally two approaches: one is to create an HTML page in the assets directory to display error messages. When an error occurs and onReceivedError() is called, we can use webView's loadUrl to navigate to our error page, such as: wView.loadUrl("file:///android_asset/error.html"); Alternatively, we can design a layout or simply display a large image that is normally invisible, but becomes visible when a page error occurs! Below, we'll write a simple example!


1. Page Error, Load Custom Web Page:

Running Effect Diagram:

Follow on WeChat

❮ Sql Join Image Explain Es6 Reflect Proxy ❯