SL4A - Configuring Your Device
At times, you may want to write scripts on the device and execute them. The Scripting Layer for Android helps achieve the same. To install SL4A on your device, follow the steps given below −
Download the SL4A.apk file on your device.
Launch the .apk file from the notifications screen.
Select Install on the next screen to actually install SL4A.
Alternatively, if you choose to use an emulator as against an android device, install SL4A using the browser inside the emulator. The SL4A installation initial screen on a device is shown below.
Adding the Python Interpreter
To install the python interpreter on a device, follow the steps given below −
Step 1 − Start the SL4A application.
Step 2 − Click the Menu button.
Step 3 − A list of options will be displayed. Select View.
Step 4 − Select the Interpreter option from the dialog box. Click Add.
Step 5 − A list of interpreters available for download is displayed. Select Python 2.62 (or greater).
To install python interpreter on an emulator, follow the steps given below −
Step 1 − Ensure that the emulator is running in the background.
Step 2 − Download python_for_android_rx.apk.
Step 3 − In the terminal command-line shell, navigate to the location where the apk file is stored and type the following on the command line −
adb install python_for_android_rx.apk
SL4A supports scripting engine for multiple languages. A list of some language specific apk files are mentioned below −
Connecting to Windows OS
Step 1 − Download and Install the USB Driver for Windows.
Step 2 − Setup your device −
Start SL4A from All apps screen on the device.
Tap the Menu button → View.
Choose the interpreters from the list.
Tap the Menu button → Start Server.
Select Public (to connect over Wi-Fi) or Private(to connect over USB).
Step 3 − Add an environment variable (User variable) AP_PORT and value 9999.
Android SDK and Eclipse have been discussed in the subsequent chapters.