Issue
An APP is using webview to display a site as if it were an app. I want to make that APP open the reader when a PDF is downloaded. Is this possible?
Solution
If you are using a Webview then one way you could handle the PDF is to bind an object that extends WebViewClient to your WebView using the setWebViewClientMethod. The object that extends the WebViewClient will need to override the onLoadResource method.
Inside this method then check your URL for the pdf extension, or for some other attribute of the URL that indicates a PDF, and fire off a new view intent using the PDF URL. This should either offer to open a PDF in an appropriate app. If you want to have a more paranoid fallback you could use Google's PDF renderer by prefixing your URL with http://docs.google.com/viewer?url= then URL encoding the original URL to be opened, for example http://research.google.com/archive/bigtable-osdi06.pdf becomes http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.google.com%2Farchive%2Fbigtable-osdi06.pdf.
Answered By - marcus.ramsden
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.