Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing python (or any other SL4A) in android [closed]

Can someone point me to a tutorial on using the android scripting enviornment? I've seen plenty of tutorials on how to write python code using the android API especially from http://code.google.com/p/android-scripting/wiki/Tutorials.

But none of what I've seen gives a good example of how this all works inside android or how to call your python stuff from an android application. I'm looking for a tutorial that basically can bring it all together just so I can see an example of an actual android app running python scripts.

like image 674
Falmarri Avatar asked Sep 28 '10 23:09

Falmarri


1 Answers

Note: All this was tested on my Samsung Galaxy S running Android 2.2. YMMV.

I never thought of running Python on android till I saw this. Thanks :)
I installed the SL4A app and tried out a simple Shell script. I am installing the Python interpreter and will be trying out a hello world soon.

The step were straight forward:
1. Download the app (it.s not on the market so get it from http://code.google.com/p/android-scripting/)
2. Create a shell script by clicking the Add button and choosing Shell in the options that pop-up
3. Write your code.
4. Select "Save and Run" (or "Save and Exit" and click on the script name in the main window)
5. At this point your script's output should show up in the terminal window.

Now I am trying to install the Python interpreter. Will keep the thread updated but I guess this will be same set of steps. I am having a lot of issues downloading the files - the download is slow and keeps closing.

I don't know if you can call these scripts from an Android appln. The intention of the project seems to be the other way around. But what do I know!

Edit: Continuing with my experience with Python.
1. Open SL4A and go to View->Interpreters menu. If Python isn't listed then select Add from the menu.
2. This will download an apk which you install (make sure install non-market applications is available)
3. Open the Python for Android app. It has a single button "Install"
4. Click on the Install and wait... and wait... Don't use the phone till this the install is there seems to be bug in this app so if you use any other app on the phone or tab away from this one the download gets cancelled!!!
5. After a successful install return to SL4A you should now see Python in the Interpreters and a lot of sample Python scripts.
6. The samples seem to cover quite a bit of the APIs. I was quite impressed by what I saw.

Edit: Since the original post I have also tested on a Galaxy S2 running Android 4.0. with similarly impressive results.

like image 191
SidJ Avatar answered Oct 05 '22 09:10

SidJ