Mittwoch, 27. Juni 2012

Android-Binding for GNU Smalltalk ready!

Essentially it's no big thing - just a few lines of Smalltalk-code: i created a GNU Smalltalk star Package including the "Android" class that gives access to the full Android API via SL4A.
Usage is simple. First file in the package with:

PackageLoader fileInPackage: 'Android'.

Then you can use it like this:

| android |
android := Android new.
android makeToast: 'Hello World!'.

A more complex example, using some dialogs, is included in the smalltalk_for_android.apk (you can use the QR-Code below to install the apk - but remember that you need to install sl4a before. See my previous blog-post).
To get an idea what is possible, see the the API reference. I think it is a wonderful perspective to write full blown Android apps with Smalltalk.
Coding Smalltalk on a phone or tablet is fun - the sl4a editor is a big help because it contains an api reference. If you want to hack more complex scripts, you can remote control your phone or emulator, just follow this instructions. Only one difference: you need to set the environment-variable AP_HANDSHAKE to some arbitrary value.
With this setup you can execute your script with "gst myscript.st" or just call the api via the gst console.
Sourcecode etc. is available on github.


Mittwoch, 13. Juni 2012

GNU Smalltalk on Android

I crosscompiled GNU Smalltalk 3.2.4 with the Android NDK (r8).
Because interaction with GST on Android was complicated (couldn't read stdout/ stderr reliable), i decided to use the Android Scripting Framework.
So if you want to try it, first you need to install SL4A. You should install the sl4a_r5.apk (not r4!)
After installing SL4A, you can download and install smalltall_for_android.apk. Remember to allow installation from untrusted sources.
I tested "smalltalk for android" with an android virtual device running Android 2.3.3. The Screenshot was made on my Samsung Galaxy S3.
Currently there is no binding for the SL4A API - you can execute Smalltalk code, but there is no interaction with the Android API.
So, if anyone would like to help implementing the JSON-RPC bridge to SL4A - that would be really great.
The Source is on github.