Ide
Ide

Reputation: 65

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.

Upvotes: 0

Views: 141

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007533

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);

Upvotes: 1

Related Questions