Search code examples
androidpdfandroid-intentlaunch

open a particular file by default in an already installed 3rd party app?


Is it possible to open a particular PDF file in a 3rd party PDF reader (e.g. Adobe reader) by default on start up of the application by passing an intent from my android app?

Is this possible? How should the intent be passed to achieve this?


Solution

  • Yes it's possible.

    You will need to launch an Intent with ACTION_VIEW with corresponding mime type, and the document should be opened in a 3d party pdf reader, if any available on your phone.

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