Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate Python scripting in my Android App (like SL4A)

I need to add scripting layer to my android App. So I can remotely prepare a script that my app download form a web service and execute on the user device.

I found a interesting project called Scripting Layer for Android (SL4A) here:

http://code.google.com/p/android-scripting/

I'm not sure I can execute Python script without installing the PythonForAndroid_r4.apk first. I can't force my customer to install that application!

So my question is, can the SL4A layer be integrated in my app without the need to install other apk?

I need to execute actions like update data in the DB, create/read/delete a file on the sd card... Not so complex but I see SL4A can do a lot of things like these.

Other scripting libraries?

EDIT: Found also MVEL: http://mvel.codehaus.org/ but I think it needs to be integrated to execute complex operations like accessing a DB...

like image 799
Seraphim's Avatar asked May 24 '13 08:05

Seraphim's


1 Answers

I found a project that uses SL4A:

http://code.google.com/p/android-python27/

For whom that wants to try it, if error occurs using Eclipse, here is a link that could solve the compilation issue:

http://code.google.com/p/android-python27/issues/detail?id=1

I've just compiled this project:

http://code.google.com/p/android-python27/source/browse/#hg%2Fapk

To download sources, download HG Tortoise from:

http://tortoisehg.bitbucket.io/download/

Make a local copy of the repository with the command:

hg clone https://code.google.com/p/android-python27/ 

Then import the APK project in Eclipse and compile it.

Just run it on my low cost China tablet and it seems to works fine. Initially the program make an installation:

boolean installNeeded = isInstallNeeded();

if(installNeeded) {
  setContentView(R.layout.install); 
  new InstallAsyncTask().execute();
}

That make some installations on the external storage (fortunately no root privileges are needed).

like image 170
Seraphim's Avatar answered Oct 20 '22 00:10

Seraphim's