pdf - manipulate clicked link in WebView Android -
i have webview in android application loaded local page have pdf links looks like:
<a href="pdf:document.pdf">document</a>
my need when user click on link change url , redirect user "http://url/pdf_files/document.pdf". code not working. i've search lot of information , tried lot.
my code below:
webview = (webview) v.findviewbyid(r.id.webview); webview.getsettings().setjavascriptenabled(true); webview.getsettings().setloadsimagesautomatically(true); webview.getsettings().setloadwithoverviewmode(true); webview.getsettings().setusewideviewport(true); webview.getsettings().setpluginstate(websettings.pluginstate.on); webview.setscrollbarstyle(webview.scrollbars_outside_overlay); webview.loadurl("files://assets/localpage.html"); webview.setwebviewclient(new webviewclient(){ @override public boolean shouldoverrideurlloading(webview view, string url) { string[] file_name = url.split(":"); url = "http://url/pdf_files/"+file_name[1]; view.loadurl(url); return true; } });
thanks!
if file stored in local file system use file://url/pdf_files/ may solve problem
Comments
Post a Comment