I have an app which displays results in webView. Results may include formats like .pdf, .ps, .dwf, .kml, .kmz, .xls, .ppt, .doc, .docx, .rtf and .swf
Now when user click on .pdf type link the I would like to display apps which can support pdf format like "google docs", "pdf reader" etc. Similarly, when user clicks any .swf
file then apps which support swf files like "swf player"get listed in the intent.
I have download listener like this:
webView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setDataAndType(Uri.parse(url).normalizeScheme(), Intent.normalizeMimeType(mimetype));
startActivity(Intent.createChooser(intent, "Open link via..."));
}
});
But I didn't get expected results.
How to achieve this ?
I don't want to download the file first and then open it. Also, I avoid using this approach:webView.loadUrl("http://docs.google.com/gview?embedded=true&url=http://example.com/xyz.pdf");