Downloading image file into WebView Android -
i have arcive of several files format jpg, pdf, zip , want download files app. pdf , zip files being downloaded can not download jpg files. idea how can download jpg files well?
html page here http://www.sotkora.com/xy/ex_download.html
public class downloadingexample extends activity { webview webview; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_downloading_example); this.webview=(webview) this.findviewbyid(r.id.webview_if); this.webview.getsettings().setsupportzoom(false); this.webview.getsettings().setjavascriptcanopenwindowsautomatically(false); this.webview.loadurl("http://sotkora.com/xy/ex_download.html"); this.webview.setwebviewclient(new webviewclientdemo()); this.webview.setdownloadlistener(new downloadlistener() { public void ondownloadstart(string url, string useragent, string contentdisposition, string mimetype, long contentlength) { uri uri = uri.parse(url); intent intent = new intent(intent.action_view,uri); startactivity(intent); } }); } private class webviewclientdemo extends webviewclient { @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return true; } }
html code:
<div><a href="http://www.sotkora.com/xy/images/rose.jpg" download="jpgphoto">download jpg photo</a></div><br/> <div><a href="http://www.sotkora.com/xy/files/load_test.pdf" download="pdf_test">download pdf file</a></div><br/> <div><a href="http://www.sotkora.com/xy/files/load_test.zip" download="zip_test">download zip file</a></div><br/>
if using proper headers downloading should able following... (you need implement own download process)
mwebview.setdownloadlistener(new downloadlistener() { public void ondownloadstart(string url, string useragent, string contentdisposition, string mimetype, long contentlength) { // download via android code } });
Comments
Post a Comment