SL4A has three main components. They are as follows −
In this chapter, we will discuss more about these three components.
SL4A acts a scripting host. It supports many scripting languages such as Python, Ruby, Lua, BeanShell, JavaScript and TCL . SL4A can be extended by incorporating new scripting languages dynamically by developing a new SL4A interpreter for that scripting language.
Each script runs in its own interpreter instance. Hence, multiple scripts can run simultaneously without affecting each other.
Scripts running within the interpreter instance communicates with the SL4A application through the Android Proxy RPC Client. The client establishes a Remote Procedure Call (RPC) connection to SL4A, and allows scripts to interact with the Android Framework. The SL4A facades facilitate this communication. Data is sent as JSON payloads.
Android RPC clients are provided for every supported scripting language. The client modules can be obtained from the SL4A website at https://code.google.com.
The façade simplifies the script’s access to the underlying Android API. SL4A exposes the Android Framework API to scripts through an extensive set of facades like AndroidFacade, BluetoothFacade, ActivityManagerFacade, CommonIntentsFacade, etc.
SL4A functionality offers a basket of rich functionalities like Camera, Location, Battery Manager, Media Player, Media Recorder and many more.
The SL4A system is suited for the following kinds of tasks −
RAD programming − With SL4A, it is possible to use Rapid Application Development (RAD) approach to create a prototype application quickly. You can create a full-blown Android application if the feasibility of the idea is confirmed.
Test scripts − It can be used to write test scripts.
Building Utilities − Utility scripts or tools that perform small tasks or automate certain aspects of repetitive tasks can be built using SL4A.