mindia
mindia

Reputation: 7759

Open Pdf from url in Android application

I work with Android and I want to open PDF file:

  1. from URL
  2. from Internal storage.(where put my file to Android read it?)

Can somebody help me?

Upvotes: 0

Views: 9028

Answers (1)

Ayush
Ayush

Reputation: 3999

Assuming there is a PDF viewer application installed on the device

To open the PDF in application use:

Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

where file is the path of PDF File.

Upvotes: 3

Related Questions