0

Hi I try to change the normal "No internet connection" page from android browser to a costum error page within my webapp. While doing this I found this link and in the answer was a well solution for binding a error page into my activity.

The problem with this solution is that my Url http://192.167.0.45/loc/index.php wont become loaded and only after any seconds the file myerrorpage.html become showed . How can my url become loaded and the other url only in error case? It look like the second mWebview.loadUrl override the first...

@Override
public void onCreate(Bundle savedInstanceState) {


    setContentView(R.layout.activity_localy);
    mWebView = (WebView) findViewById(R.id.webview);
    // Brower niceties -- pinch / zoom, follow links in place
    mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    mWebView.setWebViewClient(new GeoWebViewClient());
    // Below required for geolocation
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setGeolocationEnabled(true);
    mWebView.setWebChromeClient(new GeoWebChromeClient());     
    // Load google.com
    mWebView.loadUrl("http://192.167.0.45/loc/index.php");

   super.onCreate(savedInstanceState); mWebView.setWebViewClient(new WebViewClient() {
   public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            mWebView.loadUrl("file:///android_asset/myerrorpage.html");

        }
    }); 
}
Community
  • 1
  • 1
Bodoppels
  • 406
  • 7
  • 24

1 Answers1

1

It looks like you're not able to load the url you gave, so it jumps to the onReceivedError method, which then displays myerrorpage.html. The reason it takes time is because it has to confirm it cannot make a connection to the host.

liquidsystem
  • 634
  • 5
  • 15