Sunday, 21 December 2014

How to open a PDF via Intent from SD card

  By starting activity with intent of ACTION_VIEW, for "application/pdf", we can ask the installed       PDF ready to open PDF file from our app.


File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/example.pdf");

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

No comments: