Opening files within an application instead of default file viewer - android

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?

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.

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.

Related

Detecting photo action in android

Hey I'm stuck with this problem for quite a while
I need to have a backround activity in android which will be running to detect any photo/video activity, the minute a photo or video is taken it should make an entry into a text file:
The entry should look like this : [uri_of_new_photo, time, gps-location]
What are the possible ways in which i can achieve this, I was looking at the BroadcastReciever, but was not sure if that would work.
Are there any tutorials/links which can give me a solution. A direct solution to this problem would be great!! (rather than alternatives, as this is a small part of a bigger project)
What are the possible ways in which i can achieve this
Technically, it's not possible. Anyone is welcome to write a camera application that takes photos or videos and does not tell you about them.
I was looking at the BroadcastReciever, but was not sure if that would work.
I am not sure what "the BroadcastReceiver" is that you are referring to.
You are welcome to use FileObserver to try to monitor likely places for photos and recorded videos. However, there is no guarantee that apps will write their photos or recorded videos in the places that you are looking. And, just because there is a new file in one of those directories does not mean that the user took a photo or recorded a video -- they could have simply copied a file into that directory, or obtained the file from the Internet (e.g., Flickr sync). And, this will only work while your app is running.
You are welcome to use a ContentObserver on MediaStore. It will suffer from the same basic problems as would the FileObserver approach that I mentioned.
If you want to reliably log information about the time and location of photos and videos, write your own camera app.

Pdf in android without other applications

I want to show pdf file in android, but this must work without Internet connection and other appliacation. Can I show pdf file in webView or other view?
Yes you can show your PDF to your custom view. For, this you've to use one External Jar file for that. I've already answered like similar to your question. Just check it out.
Hope this helps you.
Using another app to display your PDFs is a really nice way to do it. Unless you have superiors forcing you to avoid other apps, I'd do it that way. There are good, free pdf viewing apps available so it won't cost your users anything.
The transition when opening a pdf in another app is pretty seamless and it's not always obvious that another app is being used.
The alternative, as SpK said, is to use a jar and write the extra pdf viewing functionality that you need. This is a much harder way to do it.

Add and load images, videos and pdfs from a raw folder or an SDCard Android Tablet design?

Good day, I have a requirement to create a kind of book app with pdfs, images and videos worth up to 10gb and more on a tablet locally. Now there is no intention to sell it on the android market or any other store, its completely in house, so i think issue with apk size has been clarified. What am asking is, where is the best place to put all this contents so that i can readily load them up and use them accordingly?
Should i be using the raw folder and create sub-folders for each images, videos and pdfs?
Should i create folders on an sdcard(assuming there is one in place)? or
Please if you have any other solution or ideas on how to implement this, I would gladly like to hear this. Thanks for your responses in advance.
P.S by the way, since its a tablet specific app, is there any need to have a multi-pane layout fragment or ii can just use all the space. thank you
I suppose you can use a RAW folder, but it would also make the APK size huge from what I understand because all the files in the RAW folder need to be packaged with the application.
From what I've seen in the past, most applications, actually most games, that have lots of extra data will download the additional data on first launch. Basically:
The application launches
It checks whether or not you have all the additional data (Books, pdfs, images)
If not, it starts downloading that data to the SDCARD.
It may not make sense in your situation, but doing it this way gives you more finite control over how much data needs to be downloaded. If function A only requires package A of additional data, then you only need to download package A, you don't need to download everything. Or perhaps you could let the user choose what packages of additional data they want to download, which would also save bandwidth, time and resources.

Video 'Snipping' Android - Possible?

Hey guys, I'm looking into creating an application that requires a video file taken on the mobile phone, open it and allow the user to cut the video using two sliders, one for IN(the beginning) and the other for out(end of the clip you want), this will then create a new file and my app will use it then.
Does this sound feasible? Where should I start looking in order to do this quite simple concept? Does anyone have any ideas?
Thanks
Android SDK has no video-editing (not even cropping) capabilities. So you'd need to write your own.
To do this you'd need to know 3gpp video/audio file format and also a way to decode the file (for showing in the UI).
This is by no means a trivial task.

Produce thumbnail from pdf on Android

I am managing a bunch of PDF files in an android application maintaining a list of records in a SQLite database as well as storing the pdf files on the external storage.
Now I would like to present a thumbnail of the first page of the pdf in my list view as part of each cell representing a pdf.
I am aware of libraries like iText, fop.. on the JavaSE side that can render a PDF but I would rather not delve into embedding a large library like that. On a similar approach I would also rather not embed a native PDF viewer like droidreader, apv or vudroid.
Otherwise I could of course also get it rendered on a server via some webservice but that is a lot of headache as well.
I am already using intents to get the pdf's displayed for the user so I was thinking it would be great if I could get a thumbnail via a intent call as a result somehow. However I found nothing on the web (e.g. on openintents) that indicates something like that exists ..
So I am a bit at a loss on what to do? What do you think is the best approach to get these thumbnails into my app? Are there any public intents available? Or did I just totally miss something and the SDK provides features for that already (it should imho but currently does not)?
You are going to get a lot faster resopnse rasterizing the PDFs on the server and there are lots of libraries to do this in C, Java, Php.

Categories

Resources