简体   繁体   中英

Opening pdf from activity

I am developing an app which has one activity that contains a lot of text (really a lot). I thought it would be the best solution to make a PDF with the information in it and open that file right from the app. So when people open the activity, the PDF is opened in a PDF capable viewer installed.

Do you guys know how I have to work this out, because I think I will need to use an Intent, but which one? And how to direct open the viewer?

Thanks for all the help or any energy you put in this question in advance.

Do you guys know how I have to work this out, because I think I will need to use an Intent, but which one?

Use this:

 Intent i=new Intent(Intent.ACTION_VIEW);

 i.setDataAndType(Uri.fromFile(pathToYourPdfFile), "application/pdf");
 startActivity(i);

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