I am getting a pdf document as an attachment from a POST call. But I am not able to display the pdf in android webview directly. I could download the file in local storage. But due to security reasons, instead of downloading it, I need to display it within the webview itself.
I have tried several solutions :
Displaying using google docs / drive - It gives "No Preview Available" on the webview (The reason for this might be that I don't receive a pdf url in response. What I receive is the pdf document as an attachment mentioned in the POST call response as "Content-Disposition" "attachment; filename=abc.pdf".
Tried using the intent view, but nothing happens on click of the link for pdf in webview. webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } });
Is there any other way to achieve this without downloading the pdf in external storage and directly open the attachment from POST response into android webview.