Search code examples
androidhtmlwebviewreload

The webview doesn't show the newest content when using 'webview.reload()' after 'webview.loadUrl()'


  1. For the first time, invoke the method:
webview.loadUrl("https://www.google.com").

The page shows the google's content.

  1. For the second time, invoke the method :
webview.loadUrl("https://stackoverflow.com/").
webview.reload();

The page still shows the google's content. But the log shows:

webview.getUrl()-> https://stackoverflow.com/
webview.getOriginalUrl-> https://www.google.com

I am wondering how it happened and how to make it show the newest content when doesn't change App native code?

(To let h5 page to listen the 'reload' event???) Thanks!


Solution

  • You don't need to call webview.reload(); The second snippet should simply be:

    webview.loadUrl("https://stackoverflow.com/");
    

    I suspect the what you see is the result of .loadUrl() starting to load the page, but .reload() interrupting this process and reloading the current page.