Links
- android-scripting.googlecode.com/hg/python/ase/android.py
- Py4a – Python for Android
- Remote Android Scripting with Python
- RunPythonAsScript - android-scripting - How to run python from the command line
- RemoteControl - android-scripting - How to control the device while running scripts on your computer
- CodeStructure - android-scripting - A quick guide to the structure of sl4a
- InterpreterForAndroid - The link between the sl4a RPC and the various interpreters.
- Rough guide to how it all fits together
- The heart of sl4a is the RPC. Each script that is started is given it's own instance of the intepreter, a text screen (if started in foreground) and a tcp connection to an instance of the RPC.
- The main rpcHandling can be found here: android/Common/src/com/googlecode/android_scripting/jsonrpc/JsonRpcServer.java
- Default directory for scripts
/sdcard/sl4a/scripts
Snippets
# Set up SL4A to use port 2222 for the server. # Then start a private server. # Now, forward local port to the SL4A port. export AP_PORT=9999 adb forward tcp:$AP_PORT tcp:$AP_PORT # Finally, connect via python and try an example. # Run local python. python
Try this script at the interpreter. Make sure you have android-scripting.googlecode.com/hg/python/ase/android.py somewhere where you can import it
import android droid = android.Android() # This message shows up and disappears quickly. droid.makeToast("Hello, world!") # This notification disappears once you click on it. droid.notify("Title", "Hello, World") # Vibrate a tiny bit. droid.vibrate(250)
Misc
# In adb shell. alias python='sh /sdcard/chirayu/scripts/python.sh'