9

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.

Falmarri
  • 47,727
  • 41
  • 151
  • 191
  • It's not clear to me what you're looking for. You want to see an example of how to execute Python from a normal Java Android app? – Damon Dec 05 '10 at 23:11
  • You can just get the book from Apress: http://www.apress.com/9781430235699 – Carl Smith Sep 19 '13 at 02:23

2 Answers2

8

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.

SidJ
  • 669
  • 12
  • 29
3

After installing Android Scripting (SL4A) .apk have you installed Python for Android?

  1. This would surely work now whenever you start SL4A you would tap for more options
  2. you will get to see Add button just click on that create your scripts.
  3. while running it would ask for running environment choose terminal for that.
  4. The Terminal runs.
  5. First for testing Python is running on you Android or not Test the Sample programs at the SL4A.
Chitrank Dixit
  • 3,961
  • 4
  • 39
  • 59