load a downloadable link into a browser in android -
i have downloadable link https://drive.google.com/uc?id=0bw6vr2lnxb3iufjrtk5ozdljata&export=download
works on browser.
if open link using mobile browser using this
intent intent = new intent(intent.action_view, uri); intent.setflags(intent.flag_activity_no_history); startactivity(intent);
then automatically download file.
is possible download file using webview instead of default browser??
i tried
public class showdownload extends activity { private webview webview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.show_download); bundle extras = getintent().getextras(); if (extras.getstring("url") != null) { //do string url=extras.getstring("url"); toast.maketext(getapplicationcontext(), "__", toast.length_short).show(); webview = (webview) findviewbyid(r.id.webview1); webview.loadurl(url); webview.setdownloadlistener(new downloadlistener() { public void ondownloadstart(string url, string useragent, string contentdisposition, string mimetype, long contentlength) { request request = new request( uri.parse(url)); toast.maketext(getapplicationcontext(), " yesssss", toast.length_short).show(); request.allowscanningbymediascanner(); request.setnotificationvisibility(downloadmanager.request.visibility_visible_notify_completed); request.setdestinationinexternalpublicdir(environment.directory_downloads, "download"); downloadmanager dm = (downloadmanager) getsystemservice(download_service); dm.enqueue(request); } }); } }
}
i tired lot cant solution ? can 1 me solve issue ??
if want have in app download manager, refer post. provides detailed info various download options. https://stackoverflow.com/a/3028660
Comments
Post a Comment