Question

I'd like to open files such as photos, documents, music and video in my application. I've seen a lot of applications that open up the files in the device's default program for that filetype.

Is there a way to somehow view the files in my application without opening another application?

Was it helpful?

Solution

Reading files in Android is just as simple as any other Java application. Depending on what type of file you want to read and display, you will do different things, this question tells you how to read a text file. The principle for other types is about the same. For images, you can simply use BitmapFactory.decodeFile(). I don't have experience with video or audio, but MediaPlayer looks like a promising first step.

OTHER TIPS

You can do it, but only by writing your own Activity that can handle that type of media. So it can be a lot of work, depending on what you want to do. HTML, images, video, and audio are relatively easy, but if you want to do something like view PDF or office documents, you're setting yourself up for a tremendous amount of coding. Probably better just to launch someone else's viewer to view the relevant content; that's how almost everyone does it on Android.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top