Use Python to develop Android applications: Section 1 configure the Python runtime environment on the mobile phone

Source: Internet
Author: User
This section contains the following contents:

1. Download and install Scripting Layer for Android (SL4A)
2. Download and install Python for android
3. The first HelloWorld Program

1. Download and install Scripting Layer for Android (SL4A)

Scripting Layer for Android (SL4A) is an open-source project designed to provide script language support for android systems, this allows you to edit, interpret, and execute the script language directly on the android platform. These scripting languages have used a lot of encapsulated android APIs to develop android applications with rich functions and make development easier and more efficient!
This platform supports multiple scripting languages, such as Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell. You can select a language you are familiar with for development, this series of tutorials use Python as the programming script language
Address of SL4A project: http://code.google.com/p/android-scripting/
After the page is opened, you can scan the QR code on the page on your mobile phone to download the application and install it on your mobile phone, or click the QR code image, transfer the downloaded Application computer to your mobile phone for installation. If you are too lazy to go to the project homepage, scan the QR code directly:

2. Download and install Python for android

In the upper-right corner of the Project homepage, you can download a list Of all script languages supported by the application, as shown in;

Select the language you want to use and open the download page for the corresponding language environment. Similar to downloading SL4A, download the Language Pack application and install it on your mobile phone. I opened the Python page, as shown in:

After the program is installed, open the Python for Android Application. There is an Install button at the top of the application. Click this button to automatically download and decompress and Install Python-related files, after this process is completed, the Python Development Environment on your android phone is configured!

3. The first HelloWorld Program

Open the SL4A application and go to the Python sample code list. This is basically a demonstration of the main API. Some examples may be outdated and prompt that the method has expired or an exception occurs during running, you can modify at least a few codes. If you have the opportunity, I will introduce this example and the correct method in subsequent courses.
Click the Menu key, click Add, and select Python2.6.2. A new Python script file is created and named HelloPythonInAndroid. py.
Click the screen to enter the script editing area and enter the following content:

Import android
Droid = android. Android ()
Droid. makeToast ('hello, Python in android ')

After the input is complete, as shown in:

Click Menu and choose Save & Run. Congratulations, you have completed the first Android Application in Python: HelloPythonInAndroid!

Welcome to join the Douban SL4A group to discuss progress: Douban SL4A group (http://www.douban.com/group/SL4A)

The article is reproduced from:Iron ride (http://cooleep.com /)

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.