简体   繁体   中英

Can you use an intent to launch Adobe Reader or the Docs Reader to open an specific PDF in an Android machine?

On a site targeting Android OS, is there a way to create a link that will cause the OS to open a PDF that was downloaded from that site? That is, without requiring the user to manually open the PDF?

EDIT: to clarify, I want to implement something similar to this on my site:

<a href="adobe_reader/foo.pdf">Click here to open foo.pdf on your Android!</a>

This is supposed to be a link on my site that makes Adobe (or another) to launch foo.pdf , which is already stored on the android device.

They should. Try this:

                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(path, "application/pdf");
                startActivity(intent);

If any app has registered to be able to view PDFs (and both of those should have), it will launch them. Or any other app installed that claims to be able to read pdfs.

You can use combination of WebView and Google Docs Try this :

You can try using a combination of

String docName = "somedoc.pdf"
String PDF_BASE_URL = "http://docs.google.com/gview?embedded=true&url=";
mWebView.loadUrl(PDF_BASE_URL + docName);

Oh, I understand its a site

I think what you've done is sufficient, as the browsers deal with how they want to handle links. What you've done should work on most browsers if not the stock browser on android.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM