Android open a srt file to read it - java

I have .srt files on my android device.
But I don't have any program that allows me to be able to open it to be able to see what the contents of them are.
So I would like to create a simple program that allows me to be able to open the file as if it were a .txt in order to be able to read it.
The problem is how do I specify that that type of .srt extension can be opened by that program.
There is something in the android manifest that allows me to do this.
What I want to do is this:
I have my .srt files in my archive
When I click on one of these files, it must open the program to be able to read it with the file open

Related

Starting HTML/CSS/Javascript file from Java

I have written an Java code that process some data and stores it in .JSON format.
I also have HTML/CSS/Javascript file, that reads that data, and shows it in much nicer way.
So my question is, is it possible to combine Java and HTML code(in one file .jar) so that, for example on a click of a mouse Java opens HTML file in Default browser?
Thanks
Write out the html file to the filesystem (e.g. a temporary directory How to create a temporary directory/folder in Java?) and then open it using the default program: How to open a file with the default associated program

How to open file for random access in libgdx

I need to open a file in libgdx for random access, i.e. I need to be able to seek() to different parts of the file (not read sequentially).
Using libgdx I am able to access the file via Gdx.files.internal(), but libgdx's filehandlers don't support random access methods like seek(). I tried using java.io.RandomAccessFile, but it generates the exception No such file or directory, probably because the file is stored internally in the jar file.
How can I access the file using java.io.RandomAccessFile` or alternatively how can i open file for random-access in libgdx?
This needs to work on both Android and desktop platforms.
This is not a Libgdx limitation. You cannot do random access on files stored inside a JAR file (since they're compressed, you need to stream the contents). (I can't find a concise reference for this, but look at the definitions of JarFile and ZipFile: they only let you create streaming file handles).
Libgdx itself runs into this problem. It stores native libraries in a .jar file (the libgdx-natives.jar). To use the files, it extracts them to the local filesystem and uses them from there. See SharedLibraryLoader.java.
As far as I can tell there are three workarounds to chose from:
Remove the need for the random access in your code.
Stream the file from the JAR into memory, and randomly access it there
Copy the file from the JAR into local (private) storage or temp storage (hopefully this could be done once and not re-done on each run of the app).

localizing raw resources in android app

I want to serve local language content in my app. I am reading a .txt file in res/raw folder using FileReader (Buffered one). I have read that Android can automatically translate text for values/strings.xml file.
Is the same possible for raw text files. I am looking for minimal code changes.
Android does not automatically translate any files.
You as a developer can translate them and put the resources in appropriately qualified folders, like values-en, values-fr and so on.
These qualifiers work on all folders under res, including the raw folder.
No code changes are required, as Android will automatically pick the correct file upon runtime. However, you should always keep a copy in the default folder with no qualifications in case the app is run on a device for which you do not have content available.

Android - How to package documents into an app

I'm trying to create an app and have the ability to save files to /data/data/(packagename)/files or a directory similar to that. The goal would be to have a pdf or doc handler, as necessary, open the files stored on the internal storage and be viewed by the user. I have the code to get a pdf reader that is installed and display the file but I do not know how to package the files so they are installed in a directory like the one above. Also, if I am able to do this would I use getResources to access the files? How should the file structure look in eclipse to make this happen on install of the APK?
I do prefer to have the files stored internally (they are small) and not on the SD card.
I admit I am new to this and am trying to learn as I go. Thanks for the help!
As I understand your approach you only need to place your files to assets folder of your application and then just copy them to the internal storage. Read more here.

Mix sound files on android

I was trying to make a program that would take a recording from the microphone, and overlay it on an existing wav file. How would this be possible?
If you don't have to save the file as one file and just want to play it together, you can simply create 2 MediaPlayers and play them at the same time.
If you want to actually create a new file, you would need to read about WAV file structure and go from there.

Categories

Resources