This is a mirror of official site: http://jasper-net.blogspot.com/

Writing android gui using python(introduction)

| Monday, April 16, 2012
PythonForAndroid provides support for python script language on android. CLE project supports interaction between python and java, gives a common interface for multiple programming languages. And wrapandroid project encapsulates android java class with cle objects. Using the three components, programmers can write android gui programs with python directly. This article is an introduction. There will have series of articles to further explain how to programming android applications using python.

Preparing environment.
install PythonForAndroid from http://code.google.com/p/android-scripting
CLE may install from network by application automatically, you need only include starcore_android_r5.jar in the project. The file is in starcore_devfiles_r5.zip, which can be download from http://code.google.com/p/cle-for-android
Wrapandroid has two files: wrapandroid.jar and SRPWrapAndroidEngine.xml, which can be download from http:/code.google.com/p/wrapandroid-for-multilaguage/download/wrapandroid_devfiles_0_8_1.rar
Begin programming
Open eclipse, create a new android project, for example, “introduction”
Add Permission, which is used to download and install cle for the application
 Collapse | Copy Code
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
copy files : starcore_android_r5.jar and wrapandroid.jar into the project directory, and add them to java build path, as shown below.

Inline image 1

copy file : SRPWrapAndroidEngine.xml to assets directory.
edit IntroductionActivity.java

import com.srplab.wrapandroid.*;
public class IntroductionActivity extends WrapAndroidActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        StarActivity._Call("DoAssetsFile", "python", "code.py");
    }
}

Read more: Codeproject
QR: Inline image 2

Posted via email from Jasper-net

0 comments: