Skip to content Skip to sidebar Skip to footer

Change Android Webview Content (hash) Without Reloading The Url

I have 2 webviews : Webview1 and Webview2 (say). The user arrives at Webview1 (an url loads). Now when the user clicks on Webview2, I need to load a url like www.abcd.com#Page1. No

Solution 1:

I've figured it out :

Load the webview initially with the url (say www.abcd.com#Page1). Now whenever you want to update the url like www.abcd.com#Page2 (Hash value changes from Page1 to Page2), just do the following :

webView.evaluateJavascript("location.hash=\"" + url + "\";", newValueCallback<String>() {
            @OverridepublicvoidonReceiveValue(String value) {
                if(Debugging.Enabled) Log.d(TAG(), "onReceiveValue(value): " + value);
                }
        });

where url is the new hash value. i.e. Page2. Webview loads pretty fast :)

Post a Comment for "Change Android Webview Content (hash) Without Reloading The Url"