Sl4a eclipse Development Environment Construction

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.