How To View PDF File From Android App
Posted by blogmeister on
October 31, 2011

This helper method opens a PDF file from your Android app using any PDF related app installed in the smart phone. This is made possible with the use of an Intent object and setting its data and type so that it will recognize that it will be opening a PDF file.
If there is more than one app that can open PDF files, it will prompt you to choose which one you want to use to open the PDF file.
|
1 2 3 4 5 6 7 |
public static void openPdf(Context context, String filename) { File targetFile = new File(filname); Uri targetUri = Uri.fromFile(targetFile); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(targetUri, "application/pdf"); context.startActivity(intent); } |
Share the post "How To View PDF File From Android App"










