Skip to content Skip to sidebar Skip to footer

How Do I Refresh The Contents Of A Webview Everytime The App Is Launched?

I am trying to refresh the contents of my webview everytime someone launches my app.Say someone goes to a different page within the app or goes to background and then relaunches th

Solution 1:

You need to override the onResume(){} then just load the url again.

Solution 2:

onResume() is called when the activity returns to the foreground. You can place your reload in there. Something like this:

@OverrideprotectedvoidonResume(){
    super.onResume();
    webView.reload();
}

Solution 3:

You can do it like this, but make sure you check that the WebView is not null since onResume is called prior to onCreate and WebView may not exist in onResume yet!

@Override
protected void onResume() {
    super.onResume();
    if(webView != null){
        webView.loadUrl(...);
        or
        webView.reload();
    }
}

Post a Comment for "How Do I Refresh The Contents Of A Webview Everytime The App Is Launched?"