You should be using either Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit). Choose 32 or 64 bit depending on your OS.
Install the JDK 6 (Java SE 6 Update 27), if you don't have it already (JRE alone is not sufficient). If you are not sure, just install as you will be informed during the installation process if the JDK has already been installed.
Download the android-sdk_r12-windows.zip and unzip it to the C:\android folder of your PC. Please do not install using the recommended installer_r12-windows.exe.
Launch the Android SDK and AVD Manager by going to the folder C:\android\android-sdk-windows\tools and execute Android. Install the SDK Platform Android 2.2. This will take some time.
If you have an Android smartphone, installing the USB Driver for Windows is recommended
Add the location of the SDK's tools/ and platform-tools to your PATH environment variable, to provide easy access to the tools. On Windows, right-click on My Computer, and select Properties. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up, double-click on Path (under System Variables). Add the full path to the tools/ and platform-tools/ directories to the path.
In this tutorial, you will run the Python programs in the Android Emulator. Before you can launch the emulator, you must create an Android Virtual Device (AVD). An AVD defines the system image and device settings used by the emulator. For Python, you need to also include an SD card (size 256MB typical)
On your smartphone goto Settings->Applications and enable Unknown sources
Point your smartphone browser to the installation links at m.smartphonedaq.com. Install SL4A and Python.
Run Hello World to check Python installation
Install the Test EMANT380 app to check the EMANT380 Bluetooth connectivity and download driver and examples scripts.
Run Diagnostic.py to check the Python/EMANT380 installation. The Diagnostic.py will also display the version of the emant module. Note the following for the emant module:
It is a compiled python module (emant.pyc) and therefore will not appear on the SL4A scripts list
The emant modules for the smartphone and PC are different. To check
import emant
print emant.__version__
The Android version will include the word android
The Test EMANT380 app needs to have Bluetooth Enabled to run - even for scanning example scripts.
RemoteControl controls the Android phone/emulator while running Python scripts on your computer. To do that you need to download and install
Python 2.6.5 Windows Installer. This matches the Python version that SL4A/Python uses on the phone.
PyBluez 0.18 for Python 2.6 Windows Installer. PyBluez is a python wrapper around system Bluetooth resources to allow Python developers to easily and quickly create Bluetooth applications. This is required by the EMANT380 Bluetooth DAQ module.
IV: RemoteControl
RemoteControl allows you to write scripts on your computer and run them on the phone/emulator. This is possible using SL4A's "server" support.
To use remote control with your USB connected Android smartphone, you first have to install the USB Driver for your Android Smartphone.
Start an SL4A server from the Interpreter Manager. (From the SL4A frontpage, press Menu, then Interpreters, then Menu, then Start Server). Start a private server.
Note the port displayed in the SL4A notification in the Android notification area. Let's say the private server within SL4A is listening on port 4321
Start the DOS Command Prompt.
Use adb to forward the network connection to the emulator
Set the AP_PORT environment variable
adb forward tcp:9999 tcp:4321
set AP_PORT=9999
If multiple emulator/device instances are running, you need to specify a target instance when issuing adb commands. To so so, use the -s option in the command
adb -s emulator-5556 forward tcp:9999 tcp:4321
set AP_PORT=9999
To find which emulator/device instances are running, use the following adb command
adb devices
make sure you have the SL4A's android.py module in your Python path (i.e. in site-packages or the current directory). android.py is the only extra file you need; you don't need to do any sort of extensive SL4A install on your computer.
Start Python and try the following code
import android
droid = android.Android()
droid.makeToast("Hello from computer")
If you intend to run your Python scripts outside of the DOS shell, you must set AP_PORT as a global environment variable. On Windows, right-click on My Computer, and select Properties. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up, click on New System Variables. Add AP_PORT to the Variable name and 9999 to the Variable value.
Otherwise you will see the following error when you run the Python test code.
Traceback (most recent call last):
File "", line 1, in
droid = android.Android()
File "C:\Python26\android.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "C:\Python26\lib\socket.py", line 547, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
gaierror: [Errno 11001] getaddrinfo failed