Mobile Phone Communication Based on SL4A

SL4A is the scripting layer of Android, which is designed to develop Android applications with familiar scripting languages. SL4A has ability to support high-level scripting language such as Python, Perl, JRuby, Lua,BeanShell, PHP,JavaScript, Tel, shell and so on. The SL4A architecture and the process that a scripting file named myscript.py is to access Android service are shown in figure 1. As shown in figure 1, the SL4A system is composed of SL4A RPC Server components and script engines supported by SL4A .The script engines are responsible for the interpretation of the script application, The SL4A RPC Server component provides the Android primary ecosystem services to the scripts. The working principle of SL4A is based on JSON-RPC remote call, scripting application interacts with remote agent “SL4A RPC Server “via local script interpreters to access indirectly Android service in remote agent pattern . Firstly function calls of the local scripting, encapsulated in the JSON data format, are passed to SL4A RPC Server components by Scripting interpreters. After this SL4A RPC Server components call the Android functions in practice. Finally the operation results are returned to the local scripting interpreter, and then the results are put forward to scripting application for processing and displaying by the scripting interpreter.

DEVELOPMENT ENVIRONMENT CONFIGURATION

To develop Android applications using PHP script , the four softwares, such as JDK, Android SDK, SL4A and PFA must be installed. The steps are as follows: firstly the JDK isdownload and installed on the computer; second the Android SDK is download and installed on the computer; next the simulator is created; finally SL4A and PFA are installed on the simulator.

A. Download and Install the JDK JDK 5.0 of Java or higher is recommended for runningAndroid emulator. The JDK can be downloaded from the Oracle web site “http://www.oracle.com/technetwork/java/javase/downloads/index.html”. After downloading, we can run the JDK installation file and install the JDK to the specified folder. In this paper, the JDK is installed to the C: \ Program Files \Java \ JDK.

B. Download and Install the Android SDK The newer Android SDK main installation package can be downloaded from“http://dl.google.comland roid/andro id -sdk r22.2.1-Windows.Zip”. The downloaded file should be directly extracted into a specified folder. In this paper, the Android SDK files are extracted into D: \ android SDK, the main installation package contains the SDK manager, the AVD manager, and the toolkit. Then the window of android SDK Manager is opened when we double-click the SDK Manager. exe file under the directory of D: \ android SDK .The developer can select the android SDK package to install according to the need.After installed the android SDK package and opened the directory of D: \ android SDK, the complete directory structure of the Android SDK is shown in Fig.2, it includes the directories of “tools”,”system-images”, “platform-tools”,”platforms”,”build-tools”,etc. Next, the Path environment variable must be modified for adding the Android SDK directory. The paths of “D:\android-sdk-windows\tools” and “D:\android-sdk-windows\platform-tools” are added into the Path environment variable

C. Create the Simulator After the above operation, applications can be run on Android phones. If developer doesn’t have an android phone, an emulator must be created to replace an android phone. Of course, the simulator doesn’t fully simulate the phone.

D. Install SL4A and PFA on the Android Phone or Emulator Now the program file of the latest SL4A is sl4a_r6.apk. It may be downloaded from http://code.google.com/p/android-scripting/downloads/list/.After the SL4A is downloaded, the command “adb install sl4a_r6.apk” in the Windows command window will install SL4A in the running emulator. The PFA script may be downloaded from PFA official website http://www.phpforandroid.net , its corresponding file is called phpforandroid_r1.apk. After downloading the file phpforandroid_r1.apk, the next step is to execute the command “adb install phpforandroid_r1.apk ” to install PFA scripting interpreter in the Windows command window.After installing SL4A and PFA and clicking on the buttons at the bottom of the main screen to display the list of applications,the icons can be seen of SL4A and PFA. Click Here