In this post we will elaborate how you can open a video file, present on the SD card, programatically .
We will define a button in layout which will open our PDF file. We are setting onClick action a function called pdfopen which will open the video .
In java code
We will define the pdfopen function here . We define a URI with path of the PDF file . Flag is set so that the new activity is not kept in the history stack . Then the data and datatype are set
File file = new File("/sdcard/read.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
If you will compare the code with our previous code to open a video file How to Open a Video File programatically ,
you will find for pdf we are setting the path as file and for video we are directly using the path as uri . Right now I am not aware of the logic behind this but will update as soon as possible
We are good to go . Give it a try . Questions and suggestions are welcome .
Latest posts by sunny (see all)
- Kindergarten Kids Word Games - March 8, 2016
- Packt’s $5 eBonanza eBooks sale returns - December 19, 2014
- How to Hide WhatsApp Photos and Videos from Android Gallery - April 7, 2014