Saturday, 15 June 2013

android - Listen for URL fragment id change in WebView -



android - Listen for URL fragment id change in WebView -

it seems webviewclient methods such shouldinterceptrequest(), onpagestarted(), , shouldoverrideurlloading() hear url changes cause webview load new page. there way observe url changes fragment ids, i.e. index.html#fragment_id, on webview?

i know old question found out solution isn't available anywhere in stack overflow. jpetitto's reply works messes javascript if utilize hash alter routing or other such features.

i found out overriding method doupdatevisitedhistory in webviewclient can grab url's on hash change. see below snippet example.

mwebview.setwebviewclient(new webviewclient() { @override public void doupdatevisitedhistory(webview view, string url, boolean isreload) { super.doupdatevisitedhistory(view, url, isreload); // somecode run on hash change. } }

note: method fired on hash alter , url change.

android android-webview webviewclient

No comments:

Post a Comment