Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Call Python Script (via SL4A) from Java code

Is it possible to call/run a python script file from Java code on the Android platform using SL4A? Basically I have a full blown Java Android app and I have several Python scripts that scrape some information from various web pages. I would like to be able to call these python scripts with the web page and get the results back. Is this possible? If so, can anyone point me in the direction of an example or two?

Thank you, Harry

like image 915
Harry Muscle Avatar asked Jan 22 '12 19:01

Harry Muscle


People also ask

Can you call a python script from Java?

You can use Java Runtime. exec() to run python script, As an example first create a python script file using shebang and then set it executable.

How do I call a python module from Java?

Using the PythonInterpreter class allows us to execute a string of Python source code via the exec method. As before we use a StringWriter to capture the output from this execution. In this example we see how we can use the get method, to access the value of a variable.

Can we use python with Java in Android Studio?

First thing first, you can use various other languages as well for the android app development. These languages involve- Python, Java, Kotlin, C, C++, Lua, C#, Corona, HTML5, JavaScript, and some more.


1 Answers

run an SL4A script from my application?

http://code.google.com/p/android-scripting/wiki/FAQ#Can_I_run_an_SL4A_script_from_my_application?

like image 105
XcinnaY Avatar answered Oct 08 '22 17:10

XcinnaY