File Download from Webview is not working in android, I am trying this way,

半腔热情 提交于 2019-12-06 15:43:23

Based on the comments and discussion from the chat.

I have noticed that shouldOverrideUrlLoading is not being called. As, per the android documentation shouldOverrideUrlLoading

Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView

But in your case since url doesn't change in WebView address bar while clicking any of the three links. It just call javascript code javascript:__doPostBack('lnkPDF',''), which calls the post method to generate the file. If you to want use DownloadManager to download file while showing notification in notification area, you need to create dynamic static url for files like http:// or https://. E.g. http://www.somedomain/may_be_session_id/some_random_file_number_valid_for_some_time_only/file_name.pdf.

In addition to the above, let the web page change or redirect to new url, only then you will be able to capture urls in shouldOverrideUrlLoading.

Try changing your implementation of return in shouldOverrideUrlLoading to True if the host application wants to leave the current WebView and handle the url itself, otherwise return false.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!