background preloader

SL4A / Python

Facebook Twitter

Android-scripting - Scripting Layer for Android brings scripting languages to Android. SL4A's source has moved to github.

android-scripting - Scripting Layer for Android brings scripting languages to Android.

The issue tracker, wiki, and downloads will continue to be hosted here. Scripting Layer for Android (SL4A) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface that makes it easy to get things done. Scripts can be run interactively in a terminal, in the background, or via Locale. Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported, and we're planning to add more. SL4A is designed for developers and is alpha quality software. To install SL4A, you will need to enable the "Unknown sources" option in your device's "Application" settings. Still have questions? Want to learn more? You can buy "Practical Android Projects" on Amazon or directly from Apress.

What's Powered by SL4A? ApiReference - android-scripting - API Reference (release R4) - Scripting Layer for Android brings scripting languages to Android. Wiki Pages - android-scripting - Scripting Layer for Android brings scripting languages to Android. Tuto: Programmer en python (V2.6) sur un téléphone Android. Tuto: Programmer en python (V2.6) sur un téléphone Android Python est un langage de scripts, donc pas besoin de compiler le code, il suffit de cliquer sur le fichier avec la source python pour qu'il s'exécute.

Tuto: Programmer en python (V2.6) sur un téléphone Android

Revers de la médaille c'est plus lent que du code compilé (comme java ou C) et encore plus lent sur ASE à l'heure actuelle. Le projet ASE (Android Scripting Environment) se trouve à cette adresse: Installation:1)Télécharger AndroidScriptingEnvironment-0.10-2-alpha.apk (ou la version actuelle) ou plus simple scanner le code barre sur la home page du projet.2)Installer l'application sur le téléphone3)Ajouter l'interpréteur Python 2.6 (« Menu », « Add interpreter », « Python »)4)Patienter le temps du téléchargement5)Maintenant on se retrouve avec un terminal Python (« Menu », « Terminal », « Python 2.6 »)6)et un éditeur de code (« Menu », « Add script ») Pour tester ces exemples: Ces exemples sont fortement inspiré du site du projet.

Quelques exemples sur le wiki ASE: Using SL4A with Tasker. SL4A, Scripting Layer for Android, dramatically extends the capabilities of Tasker and your phone.

Using SL4A with Tasker

It's pretty easy to get it working for pre-existing scripts such as the ones linked below, and you don't have to be a programmer to use them. However, if you are not a programmer, you will find it tough going to write your own scripts. It's not for the faint-hearted, so be prepared to spend significant time learning how to use it. If that doesn't scare you off, then dive in! Note: The SL4A documentation contains lots of references to ASE. Go here to find out more about SL4A and how to install it. Then install the Python interpreter (at least) as described here. Then take a look at the following examples of how to use SL4A with Tasker. If you do develop a useful script, please contribute it to this wiki. SQLite, CouchDB and SPARQL with Scripting Layer for Android. The Scripting Layer for Android (SL4A) and the new SL4A Tablet Remix have a lot of powerful features and interestingly can be used to consume data from a variety of sources both online and offline.

The ability to work with some data sources, such as simple relational databases is built in, but thanks to the ability to add additional code libraries to this environment we also get the opportunity to work with non-relational databases and even Linked Data. In this article I will quickly show you how to work with three different types of data source using Python in SL4A: a relational database in the form of a SQLite file, a non-relational database in the form of CouchDB and Linked Data generated from Wikipedia which we will interrogate using the SPARQL language. SQLite The first option of a relational database will probably be the most familiar to a lot of developers. SL4A has support for SQLite out of the box. Import sqlite3 # Get a cursorcursor = conn.cursor() conn.close() CouchDB.