AndLua

Is a blend of jillcode, luaj, some additional android-specific classes and some custom Lua libraries. Allows to prototype Android apps within Android itself, without requiring the ADT.

Table of contents

Introduction

Lua 5.1 with the bit32 library from Lua 5.2 and some other extensions.

Features and limitations

Compiles and executes Lua scripts on the fly. The included luajava-like library allows access to a large chunk of Android's capabilities.

It is not possible to sub-class existing java classes and this approach doesn't abstract the Android platform.

Custom libraries

A minimal set of functions necessary to interact with the Android environment.

Android

android.activity

Instance of the currently running android Activity.

android.pwd
Path to the currently running script.
android.uptime([msec])

If msec is given, sets the interpreter uptime value to msec. Otherwise returns the current interpreter uptime. The time unit is always milliseconds.

android.post(task, [msec])

Task must be a reference to something the interpreter can call like a function. If msec is given, task is scheduled be called as soon as the interpreter's uptime value reaches the value given by the msec parameter. Otherwise task will be scheduled to be called as soon as possible. Returns a task id object on success, nothing on failure.

android.remove([task id])

If task id is given, removes the specified task from the background execution queue. Otherwise removes all tasks from the queue.

CryptLib

Very simple cryptography-oriented functions.

crypt.cipher

Name of the cipher algorithms to use. Defaults to "PBEWithMD5AndDES".

crypt.digest

Name of the digest algorithm to use to check for integrity and successful decryption. Defaults to "MD5".

crypt.iterations

Defaults to 64.

crypt.password()

Returns a new random password.

crypt.load(file name, password)

Loads cipher text from disk. Returns boolean true and the decrypted content on success, false and an error message on failure.

crypt.save(file name, password, plain text)

Writes cipher text to disk. Returns boolean true on success, false and an error message on failure.

JavaLib

Simplified version of the LuaJava API adapted from luaj.

java.bind(class name)

Returns a Lua object linked to the named class on success, nil on failure.

java.new(class, arguments for constructor...)

Returns a Lua object linked to a new instance of the class on success, generates an exception on failure.

java.proxy(interfaces..., table of functions)

Instantiates and implements some java interfaces.

Test programs

Compile the project or install the apk, upload the "andlua" folder from "ball.zip" inside your "/sdcard/" and navigate to it using the in-app file selector.

Links

Project page