1. Install pydev
"Help"-> "install new software"
Configure the python path
2. Create a pydev Project
3. Put the Android. py of sl4a (in the/mnt/sdcard/COM. googlecode. pythonforandroid/extras/Python directory of the mobile phone) to the new project.
4. Create a script for loading launch_app.py.
#!/usr/bin/env pythonimport subprocessADB = r'd:\Android\android-sdk\platform-tools\adb.exe'APPLICATION = 'hello.py'TARGET = '/sdcard/sl4a/scripts/'def main(): # Upload the application. subprocess.call([ADB, '-e', 'push', APPLICATION, TARGET + APPLICATION]) # Launch the application. subprocess.call('"%s" -e shell am start \ -a com.googlecode.android_scripting.action.LAUNCH_BACKGROUND_SCRIPT \ -n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher \ -e com.googlecode.android_scripting.extra.SCRIPT_PATH \ "%s%s"' % (ADB, TARGET, APPLICATION))if __name__ == '__main__': main()
5. Create hello. py
Run launch_app.py to put "Hello. py" in the mobile phone, and then run "Hello. py" in the mobile phone.
6. It is more convenient to use the ADB proxy.
A. First enable server in sl4a on the mobile phone end
B. Run in the PC command window
Set ap_port = 9999
ADB forward TCP: 9999 TCP: 9000
Among them, 9000 is the service port of sl4a on the mobile phone end.
C. Now you can run Hello. py directly on your mobile phone through ADB.