I have download Android source code and flashed it to device. I have written LKM which reads/writes information to /proc/myFile. I want to write to /proc/myFiLE file from my android activity but using java code not native. I know in native code we can can use system( ) system call to write using echo command but i do not know that how to write from java code? Thanks in advance.
Just treat them as normal files. You can use the usual File and *Stream objects to write what you need.
You can use something like this.
Runtime.getRuntime().exec("your command")
Related
In my android application, I have to concat videos of different formats and i use FFmpeg for this.I made use of the java wrapper provided by guardianproject at the below link:
https://github.com/guardianproject/android-ffmpeg-java
But this method uses the FFmpeg executable. Some of the guys suggested to avoid this approach, because we need to issue permission to run the executable s since android will not do that.
Also this can only be possible when the app's data is in phone memory.So the problem is, the app cannot be moved to sdcard. When we do so, the executable cannot be run.
I feel this method is good when compared to writing JNI. So is it possible to issue permission to a executable that can run on a sdcard.
Any help is appreciated.
You can issue permissions pragmatically to any files that resides on sd-card. Create a file object and try this
file.setExecutable(boolean); – true, allows execute, false disallows it.
I hope this works.
Has anyone managed to use acoustid (http://acoustid.org/chromaprint) in an Java application? Accessing the chromaprint clib should be easy but I can't just pass in the audio file. I requires the raw uncompressed audio data.
I've tried using xuggler to get the uncompressed audio but didn't get anywhere. Basically I have no idea how to get the raw audio from encoded files like mp3/m4a/etc
Has anybody managed to make this work? Anyone mind sharing their code?
I suggest you use the fpcalc command line tool (included in Chromaprint, binaries for Windows/Mac/Linux are included on the website), run it in a subprocess from your Java application. You get output like this, which should be easy to parse:
FILE=/path/to/file.mp3
DURATION=398
FINGERPRINT=AQADtEqkRIkkrQ...
That's how most programs integrate AcoustID and I believe it's the easiest way.
I am a beginner in the field of Data Mining. I have a data which i need to process before visualizing any useful results. So I do the following:
Preprocess data using Java Program ( Output : txt files) (Input: FileNames)
Convert .txt files to .xls files ( Excel file)
Import excel file in MATLAB
Write Matlab Script to draw some plots on the imported data
I wish to automate this process by just pressing run button and then it happens automatically.
Please guide me how to integrate my work so instead of doing these 4 steps each time i just provide input file names and all the work is done in one go.
Thanks!
You can use arbitrary Java classes from within MATLAB - it is supported to run user-defined classes and even pass data between them and MATLAB. This would give you the following benefits:
no need to write text files/XLS and then import them into matlab
write everything in one MATLAB script - that is what duffymo had in mind, just that you do not need any shell/batch processing. Everything is done in MATLAB
you could add a MATLAB-implemented GUI to handle the process
Have a look at this SO post for some insights.
You want a scripting language: Windows command if you're on that platform; shell scripts on Linux.
It might not be a button, because that implies a UI. You have to write what amounts to an application for that.
The java matlabcontrol library might come in handy
http://code.google.com/p/matlabcontrol/
I had a similar task some time ago. Matlabcontrol is a library which connects MATLAB to your Java program and is quite easy to use.
All steps can be done in Matlab environment.
Java code can be called in Matlab directly. Just add your java class path to Classpath.txt in Matlab and import in the script code.
Maybe CSV data file is better for your case.
Does anyone knows how to unmount a drive in java in OSx
I am trying to unmount a sdcard from java. I am using java Swing class and the drive gets mounted automatically, but how do I unmount it.
The concept of mounting/unmounting is not platform agnostic, so it doesn't exist directly within the Java APIs. You will most probably have to issue a command line call to unmount by using Runtime.exec()
There might be open source libraries available that wrap this exec call for you, but I'm not positive.
You could call umount using Runtime.exec. Of course, this solution is not portable.
Is it possible to start other application that are installed on the system with my java app and pass a file as a parameter to them? I have a client which receives videos from a server and I want my client program to start, lets say the VLC player with the file that I received. How do I manage to do that?
Use Desktop#open(). It will launch the platform default associated application to open the given file.
File file = new File("/absolute/path/to/file.vlc");
Desktop.getDesktop().open(file);
No need to hassle with Runtime#exec() or ProcessBuilder for which you would have to add platform detection and to write platform specific logics for.
Quite simply:
Runtime.getRuntime().exec("vlc [arguments]"); //Write all arguments as you would in your shell.
Make sure you catch all relevant exceptions
You can call the exec method on the Runtime object.
Runtime.getRuntime().exec("System specific command line text here");
You can run an external program pretty easily on Java 5+ with ProcessBuilder, including passing arguments and handling input/output streams.
eg.
ProcessBuilder movieProcess = new ProcessBuilder("/path/to/movieplayer", "/path/to.moviefile");
movieProcess.start();
Only used it myself executing non-UI stuff, I'll give it a quick go and see what happens with something like VLC.
Update - works a treat for flv on Ubuntu, UI is visible and accepts file arguments.