OpenSource For You

Running the test program

-

By now, your Android device is ready to run your PHP scripts— just start Menu and launch SL4A. TKHrH yRu ZLOO find D nuPEHr RI dHPR sFrLSWs SrRYLdHd by PFA, as you can see in Figure 1. Let’s run hello_world. php— just tap it, and then the pencil icon to edit the code, which is shown below: <?php require_once(“Android.php”); $droid = new Android(); $name = $droid -> dialogGetI­nput(“Hi!”, “What is your name?”); $droid -> makeToast(‘Hello, ’ . $name[‘result’]);

As getInput is depreciate­d by Android, and will cause an error, you must use dialogGetI­nput instead. Once done, save and run the code. The result is shown in Figures 2 and 3. As you run the code, you will see a FIX ME error message (Figure 3 top) that reads:

FIX ME! implement getprotoby­name() bionic/libc/stubs.c:378

This occurs because the bionic (Android libc) lacks getprotoby­name. However, it does not affect the output of your script. When you pack your PHP script into an apk fiOH, it gets removed. For further writing of your own scripts, you can refer to the SL4A API reference at http://code.google. com/p/android-scripting/wiki/ApiReferen­ce.

SL4A with PFA opens up Android developmen­t to the next level for Web developers, with definitely better programmin­g opportunit­ies while offering users more flexible and interactiv­e applicatio­ns. So to all developers, happy coding!

References

[1] code.google.com/p/android-scripting/ [2] www.phpforandr­oid.net

By: Yatharth A Khatri

The author is a FOSS lover who enjoys working on all types of FOSS projects. He is currently doing research on human-computer interactio­n and is an Android developer too. You can reach him regarding any software issues at yatharth01@gmail.com.

 ??  ?? If you are working with an emulator, you can do the same thing by downloadin­g the rHsSHFWLYH fiOHs WR WKH ORFDWLRn Android/android-sdk/platformto­ols/ and installing these from WKH FRPPDnd-OLnH ZLWK WKH adb LnstAOO fiOenAPe.ASN command.
Figure 1: Demo...
If you are working with an emulator, you can do the same thing by downloadin­g the rHsSHFWLYH fiOHs WR WKH ORFDWLRn Android/android-sdk/platformto­ols/ and installing these from WKH FRPPDnd-OLnH ZLWK WKH adb LnstAOO fiOenAPe.ASN command. Figure 1: Demo...
 ??  ?? Figure 3: FIX ME error
Figure 3: FIX ME error
 ??  ?? Figure 2: Run the changed ‘Hello’ script
Figure 2: Run the changed ‘Hello’ script

Newspapers in English

Newspapers from India