views-widgets-samples icon indicating copy to clipboard operation
views-widgets-samples copied to clipboard

Something wrong in the Webview's navigation

Open ShengjieGeng opened this issue 7 months ago • 0 comments

Hi, I'm using the Webview in my App, I added the useragent in the websettings, but the second page can not goback to the first page using webview.goback(). By the way, it gose well with no customizing useragent. As the codes showing below:

String userAgentString = webSettings.getUserAgentString();
webSettings.setUserAgentString(userAgentString.concat(myAgent));
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setDomStorageEnabled(true);
@Override
public void onBackPressed() {
        if (!webview.canGoBack()) {
            super.onBackPressed();
        }else{
           webview.back();
        }
}

ShengjieGeng avatar Mar 07 '25 08:03 ShengjieGeng