SlideShare a Scribd company logo
1 of 31
Download to read offline
Ivan Mosquera <ivan@ivanmosquera.net>
PHP for Android: PHP scripting on Android
PHP for Android: scripting PHP en Android
$self
● Iván Mosquera
– ZCE
– PHP, Java, C.
– PHP for Android project founder.
– @ivmos
● Irontec
– Free software company.
– Development/Systems/VoIp/Learning.
– @irontec
PHP for Android: scripting PHP en Android
Slides
● http://www.slideshare.net/ivmos
● http://www.slideshare.net/irontec
PHP for Android: scripting PHP en Android
Index
● Android.
– Intro..
– Architecture.
● PHP on Android
● PHP compilation.
● SL4A & PhpForAndroid.
● Example: script “WhereAmI”.
– PFAf
● Development and sharing.
● Questions.
PHP for Android: scripting PHP en Android
Android
● Mobile OS.
● Opensource.
● 200.000 /day.
● → tablet
PHP for Android: scripting PHP en Android
Android
PHP for Android: scripting PHP en Android
Android
PHP for Android: scripting PHP en Android
PHP on Android
● Android “is” Linux.
● So it should work.
– Of course it does..
● ARM cross compiling.
● Method 1 (easy):
– Static compilation gnu libc (> 7MB)
PHP for Android: scripting PHP en Android
PHP en Android
● Not so easy way:
– Linked to Bionic.
● Bionic: libc de Android
– BSD.
– sizeof(gnu_libc) * 0.5
– Missing stuff.
● PHP on Android.
– Php-cli sapi
– Agcc
– Tweaks because of bionic.
– =~ 2MB
– Sockets, json.
PHP for Android: scripting PHP en Android
The problem
● API php → OK
● UI? (php-gtk?)
● Calls?
● Messages?
● Location?
● Sensors?
● ...
● Mobile web.
PHP for Android: scripting PHP en Android
The solution
● Google project (Damon Kohler), opensource.
● SL4A (Scripting Layer For Android)
● Android app (APK).
● Layer for scripting languages.
● Exposes Android API.
● Really active, often releases.
PHP for Android: scripting PHP en Android
The solution
● Officially supported languages:
– Python.
– Perl.
– Ruby.
– Lua...
● Foreach interpreter → APK installer.
● PHP? → issue #40 → phpforandroid.net
http://code.google.com/p/android-scripting/issues/detail?id=40
PHP for Android: scripting PHP en Android
The PFA project
● Http://www.phpforandroid.net
● @phpforandroid
● SL4A PHP support.
● APK.
● Android PHP binary.
● Framework.
● Free software.
PHP for Android: scripting PHP en Android
APKs
● APKs:
– SL4A
– PFA
● SL4A detects PFA
(intent filter).
PHP for Android: scripting PHP en Android
PHP for Android
● Installer (that's all):
– PHP bin.
● php_rX.zip
– Scripts
● php_scripts_rX.zip
– Misc
● Android.php
● php.ini
● php_extras_rX.zip
PHP for Android: scripting PHP en Android
SL4A
● Script management.
● Android Facades.
● Interpreter install.
PHP for Android: scripting PHP en Android
PHP for Android & SL4A
● 0.1 (ASE r26 unofficial, php 5.3.3rc2)
● 0.2 (SL4A_r0, php 5.3.3rc3)
● 0.3 (SL4A_r2+, php 5.3.3)
PHP for Android: scripting PHP en Android
The Android class
<?php
include 'Android.php';
$droid = new Android();
public function __call($name, $args) {
return $this->rpc($name, $args);
}
Json RPC
PHP for Android: scripting PHP en Android
The Android class
public function rpc($method, $args) {
$data = array(
'id'=>$this->_id,
'method'=>$method,
'params'=>$args
);
$request = json_encode($data) . “n”;
$sent = socket_write($this->_socket, $request,
strlen($request));
PHP for Android: scripting PHP en Android
The Android class
$response = socket_read($this->_socket, 1024,
PHP_NORMAL_READ) or die("Could not read
inputn"); $this->_id++;
$result = json_decode($response);
return array ('id' => $result->id,
'result' => $result->result,
'error' => $result->error
);
}
PHP for Android: scripting PHP en Android
The Android class
<?php
require “Android.php”;
$droid = new Android();
$droid->viewContacts();
PHP for Android: scripting PHP en Android
“WhereAmI” script
● Location.
● Email building (google maps link).
PHP for Android: scripting PHP en Android
“WhereAmI” script
$droid->startLocating();
– Received: {"id":24,"method":"startLocating","params":[]}
– Sent: {"error":null,"id":24,"result":null}
$location = $droid->readLocation();
– Received: {"id":25,"method":"readLocation","params":[]}
– Sent: {"error":null,"id":25,"result":{"network":
{"provider":"network","time":1288215482448,"longitud
e":-
3.0339431,"latitude":43.3319985,"speed":0,"accuracy"
:76,"altitude":0}}}
PHP for Android: scripting PHP en Android
“WhereAmI” script
$droid->stopLocating();
– Received: {"id":26,"method":"stopLocating","params":[]}
– Sent: {"error":null,"id":26,"result":null}
$longitude =
$location["result"]->network->longitude;
$latitude =
$location["result"]->network->latitude;
$mapLink = sprintf('http://maps.google.com/maps?
q=%s,%s', $latitude, $longitude);
PHP for Android: scripting PHP en Android
“WhereAmI” script
$data .= "Google maps : $mapLink";
$droid->sendEmail('', 'Donde estoy', $data );
– Received: {"id":29,"method":"sendEmail","params":
["","Donde estoy","admin_area : Pau00eds Vasco
nfeature_name : 3 nsub_admin_area : Vizcaya
npostal_code : 48980 nlocality : Santurtzi
nthoroughfare : Calle del Puerto Pesquero
ncountry_code : ES ncountry_name : Espau00f1a
nnGoogle Maps: http://maps.google.com/maps?
q=13.3319985, 6.0339431"]}
– Sent: {"error":null,"id":29,"result":null}
PHP for Android: scripting PHP en Android
PFAf
● Maciej Wilgucki @wilgucki
● Framework avaiblable since PFA 0.3.
● Extend ScriptAbstract, implement init.
● Organize your script with states.
● function FooAction() {
....
$this->setNextAction('bar');
PHP for Android: scripting PHP en Android
PFAf
start
locate
credicts
info
PHP for Android: scripting PHP en Android
Development environment
● SL4A...
– Emulator, adb.
● [allow_url_fopen, allow_url_include] → ON
– testnow.php
– testcache.php
● Remote scripting.
PHP for Android: scripting PHP en Android
Script sharing
● SL4A scripts folder.
● Barcode (<4296 chars)
● Script on APK:
– Template project → customize.
– ANT
PHP for Android: scripting PHP en Android
Roadmap
● SL4A
– API extended.
● GUI...
– Bugfixes.
● PFA
– Sqlite,... phpize.
– supporting SL4A releases.
PHP for Android: scripting PHP en Android
?????
Questions
Logo @Workoholics_

More Related Content

What's hot

Dev + DevOps для PHP розробника
Dev + DevOps для PHP розробникаDev + DevOps для PHP розробника
Dev + DevOps для PHP розробникаphpfriendsclub
 
JavaScript for PHP Developers
JavaScript for PHP DevelopersJavaScript for PHP Developers
JavaScript for PHP Developersfunkatron
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y GradleAntonio Mas
 
Flutter beers and pizza
Flutter beers and pizzaFlutter beers and pizza
Flutter beers and pizzaJon Durán
 
Building Command Line Tools with Golang
Building Command Line Tools with GolangBuilding Command Line Tools with Golang
Building Command Line Tools with GolangTakaaki Mizuno
 
Best practices for joomla extensions developers
Best practices for joomla extensions developersBest practices for joomla extensions developers
Best practices for joomla extensions developersFrancesco Abeni
 
Feedback from an eclipse plugin developer to provide support to large set of ...
Feedback from an eclipse plugin developer to provide support to large set of ...Feedback from an eclipse plugin developer to provide support to large set of ...
Feedback from an eclipse plugin developer to provide support to large set of ...Aurélien Pupier
 
Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會
Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會
Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會LaravelDojo
 
DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007Tim Bunce
 
Let the contribution begin
Let the contribution beginLet the contribution begin
Let the contribution beginSeongJae Park
 
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
 [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
[INNOVATUBE] Tech Talk #3: Golang - Takaaki MizunoNexus FrontierTech
 
Code analysis for a better future
Code analysis for a better futureCode analysis for a better future
Code analysis for a better futuregilforcada
 
Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1Stefan Fodor
 
CodeIgniter4 PHPCon 2016
CodeIgniter4  PHPCon 2016CodeIgniter4  PHPCon 2016
CodeIgniter4 PHPCon 2016Takako Miyagawa
 
Make your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsMake your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsNataly Tkachuk
 

What's hot (20)

Dev + DevOps для PHP розробника
Dev + DevOps для PHP розробникаDev + DevOps для PHP розробника
Dev + DevOps для PHP розробника
 
JavaScript for PHP Developers
JavaScript for PHP DevelopersJavaScript for PHP Developers
JavaScript for PHP Developers
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y Gradle
 
Flutter beers and pizza
Flutter beers and pizzaFlutter beers and pizza
Flutter beers and pizza
 
Building Command Line Tools with Golang
Building Command Line Tools with GolangBuilding Command Line Tools with Golang
Building Command Line Tools with Golang
 
plone.api
plone.apiplone.api
plone.api
 
Best practices for joomla extensions developers
Best practices for joomla extensions developersBest practices for joomla extensions developers
Best practices for joomla extensions developers
 
Feedback from an eclipse plugin developer to provide support to large set of ...
Feedback from an eclipse plugin developer to provide support to large set of ...Feedback from an eclipse plugin developer to provide support to large set of ...
Feedback from an eclipse plugin developer to provide support to large set of ...
 
Beyond QA
Beyond QABeyond QA
Beyond QA
 
Groovy android
Groovy androidGroovy android
Groovy android
 
Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會
Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會
Laravel 道場帶你看 Laracon AU 2018 - 考察小組心得分享會
 
DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007
 
Let the contribution begin
Let the contribution beginLet the contribution begin
Let the contribution begin
 
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
 [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno [INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
[INNOVATUBE] Tech Talk #3: Golang - Takaaki Mizuno
 
Code analysis for a better future
Code analysis for a better futureCode analysis for a better future
Code analysis for a better future
 
Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1Special Subject 1+2: RoR 1
Special Subject 1+2: RoR 1
 
CodeIgniter4 PHPCon 2016
CodeIgniter4  PHPCon 2016CodeIgniter4  PHPCon 2016
CodeIgniter4 PHPCon 2016
 
Go lang
Go langGo lang
Go lang
 
Dot net
Dot netDot net
Dot net
 
Make your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsMake your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On Rails
 

Viewers also liked

Redis – What, Why, When, How?
Redis – What, Why, When, How?Redis – What, Why, When, How?
Redis – What, Why, When, How?Kinn Julião
 
Segurança TDC 2011
Segurança TDC 2011Segurança TDC 2011
Segurança TDC 2011Kinn Julião
 
Redis um banco chave valor
Redis um banco chave valorRedis um banco chave valor
Redis um banco chave valorKinn Julião
 
PHP for Android: scripting PHP en Android
PHP for Android: scripting PHP en AndroidPHP for Android: scripting PHP en Android
PHP for Android: scripting PHP en AndroidIrontec
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

Viewers also liked (6)

Phpforandroid
PhpforandroidPhpforandroid
Phpforandroid
 
Redis – What, Why, When, How?
Redis – What, Why, When, How?Redis – What, Why, When, How?
Redis – What, Why, When, How?
 
Segurança TDC 2011
Segurança TDC 2011Segurança TDC 2011
Segurança TDC 2011
 
Redis um banco chave valor
Redis um banco chave valorRedis um banco chave valor
Redis um banco chave valor
 
PHP for Android: scripting PHP en Android
PHP for Android: scripting PHP en AndroidPHP for Android: scripting PHP en Android
PHP for Android: scripting PHP en Android
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similar to PHP for Android: Script PHP on Android

Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHPEric Johnson
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)Eric Johnson
 
Business management application
Business management applicationBusiness management application
Business management applicationPritam Tirpude
 
How to learn to code
How to learn to codeHow to learn to code
How to learn to codeAmit Kumar
 
Android Hello World 4 Dummies (Non programmers) (pdf)
Android Hello World 4 Dummies (Non programmers) (pdf)Android Hello World 4 Dummies (Non programmers) (pdf)
Android Hello World 4 Dummies (Non programmers) (pdf)lextemp
 
Android Scripting
Android ScriptingAndroid Scripting
Android ScriptingJuan Gomez
 
Open Social Shindig Preso for FB and OpenSocial Meetup
Open Social Shindig Preso for FB and OpenSocial MeetupOpen Social Shindig Preso for FB and OpenSocial Meetup
Open Social Shindig Preso for FB and OpenSocial MeetupChris Schalk
 
Dayton webusers creatinghybridapps-webedition
Dayton webusers creatinghybridapps-webeditionDayton webusers creatinghybridapps-webedition
Dayton webusers creatinghybridapps-webeditionMartin Davis III
 
Node in Production at Aviary
Node in Production at AviaryNode in Production at Aviary
Node in Production at AviaryAviary
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakAbraham Aranguren
 
Codemotion 2012 Rome - An OpenShift Primer
Codemotion 2012 Rome - An OpenShift PrimerCodemotion 2012 Rome - An OpenShift Primer
Codemotion 2012 Rome - An OpenShift PrimerEric D. Schabell
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressiveMilad Arabi
 
Openshift: Deployments for the rest of us
Openshift: Deployments for the rest of usOpenshift: Deployments for the rest of us
Openshift: Deployments for the rest of usAnurag Patel
 
Pender presentation 2.0
Pender presentation 2.0 Pender presentation 2.0
Pender presentation 2.0 PhoneGap
 
Android Development...Using Web Technologies
Android Development...Using Web TechnologiesAndroid Development...Using Web Technologies
Android Development...Using Web TechnologiesCommonsWare
 
Build and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsBuild and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsJeff Hull
 

Similar to PHP for Android: Script PHP on Android (20)

Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)
 
Business management application
Business management applicationBusiness management application
Business management application
 
How to learn to code
How to learn to codeHow to learn to code
How to learn to code
 
Android Hello World 4 Dummies (Non programmers) (pdf)
Android Hello World 4 Dummies (Non programmers) (pdf)Android Hello World 4 Dummies (Non programmers) (pdf)
Android Hello World 4 Dummies (Non programmers) (pdf)
 
Android Scripting
Android ScriptingAndroid Scripting
Android Scripting
 
Open Social Shindig Preso for FB and OpenSocial Meetup
Open Social Shindig Preso for FB and OpenSocial MeetupOpen Social Shindig Preso for FB and OpenSocial Meetup
Open Social Shindig Preso for FB and OpenSocial Meetup
 
Dayton webusers creatinghybridapps-webedition
Dayton webusers creatinghybridapps-webeditionDayton webusers creatinghybridapps-webedition
Dayton webusers creatinghybridapps-webedition
 
Hybrid HTML5 Apps
Hybrid HTML5 AppsHybrid HTML5 Apps
Hybrid HTML5 Apps
 
Node in Production at Aviary
Node in Production at AviaryNode in Production at Aviary
Node in Production at Aviary
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreak
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
 
Codemotion 2012 Rome - An OpenShift Primer
Codemotion 2012 Rome - An OpenShift PrimerCodemotion 2012 Rome - An OpenShift Primer
Codemotion 2012 Rome - An OpenShift Primer
 
PHP as a Service TDC2019
PHP as a Service TDC2019PHP as a Service TDC2019
PHP as a Service TDC2019
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend Expressive
 
Openshift: Deployments for the rest of us
Openshift: Deployments for the rest of usOpenshift: Deployments for the rest of us
Openshift: Deployments for the rest of us
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 
Pender presentation 2.0
Pender presentation 2.0 Pender presentation 2.0
Pender presentation 2.0
 
Android Development...Using Web Technologies
Android Development...Using Web TechnologiesAndroid Development...Using Web Technologies
Android Development...Using Web Technologies
 
Build and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 MinsBuild and Deploy a Python Web App to Amazon in 30 Mins
Build and Deploy a Python Web App to Amazon in 30 Mins
 

PHP for Android: Script PHP on Android

  • 1. Ivan Mosquera <ivan@ivanmosquera.net> PHP for Android: PHP scripting on Android
  • 2. PHP for Android: scripting PHP en Android $self ● Iván Mosquera – ZCE – PHP, Java, C. – PHP for Android project founder. – @ivmos ● Irontec – Free software company. – Development/Systems/VoIp/Learning. – @irontec
  • 3. PHP for Android: scripting PHP en Android Slides ● http://www.slideshare.net/ivmos ● http://www.slideshare.net/irontec
  • 4. PHP for Android: scripting PHP en Android Index ● Android. – Intro.. – Architecture. ● PHP on Android ● PHP compilation. ● SL4A & PhpForAndroid. ● Example: script “WhereAmI”. – PFAf ● Development and sharing. ● Questions.
  • 5. PHP for Android: scripting PHP en Android Android ● Mobile OS. ● Opensource. ● 200.000 /day. ● → tablet
  • 6. PHP for Android: scripting PHP en Android Android
  • 7. PHP for Android: scripting PHP en Android Android
  • 8. PHP for Android: scripting PHP en Android PHP on Android ● Android “is” Linux. ● So it should work. – Of course it does.. ● ARM cross compiling. ● Method 1 (easy): – Static compilation gnu libc (> 7MB)
  • 9. PHP for Android: scripting PHP en Android PHP en Android ● Not so easy way: – Linked to Bionic. ● Bionic: libc de Android – BSD. – sizeof(gnu_libc) * 0.5 – Missing stuff. ● PHP on Android. – Php-cli sapi – Agcc – Tweaks because of bionic. – =~ 2MB – Sockets, json.
  • 10. PHP for Android: scripting PHP en Android The problem ● API php → OK ● UI? (php-gtk?) ● Calls? ● Messages? ● Location? ● Sensors? ● ... ● Mobile web.
  • 11. PHP for Android: scripting PHP en Android The solution ● Google project (Damon Kohler), opensource. ● SL4A (Scripting Layer For Android) ● Android app (APK). ● Layer for scripting languages. ● Exposes Android API. ● Really active, often releases.
  • 12. PHP for Android: scripting PHP en Android The solution ● Officially supported languages: – Python. – Perl. – Ruby. – Lua... ● Foreach interpreter → APK installer. ● PHP? → issue #40 → phpforandroid.net http://code.google.com/p/android-scripting/issues/detail?id=40
  • 13. PHP for Android: scripting PHP en Android The PFA project ● Http://www.phpforandroid.net ● @phpforandroid ● SL4A PHP support. ● APK. ● Android PHP binary. ● Framework. ● Free software.
  • 14. PHP for Android: scripting PHP en Android APKs ● APKs: – SL4A – PFA ● SL4A detects PFA (intent filter).
  • 15. PHP for Android: scripting PHP en Android PHP for Android ● Installer (that's all): – PHP bin. ● php_rX.zip – Scripts ● php_scripts_rX.zip – Misc ● Android.php ● php.ini ● php_extras_rX.zip
  • 16. PHP for Android: scripting PHP en Android SL4A ● Script management. ● Android Facades. ● Interpreter install.
  • 17. PHP for Android: scripting PHP en Android PHP for Android & SL4A ● 0.1 (ASE r26 unofficial, php 5.3.3rc2) ● 0.2 (SL4A_r0, php 5.3.3rc3) ● 0.3 (SL4A_r2+, php 5.3.3)
  • 18. PHP for Android: scripting PHP en Android The Android class <?php include 'Android.php'; $droid = new Android(); public function __call($name, $args) { return $this->rpc($name, $args); } Json RPC
  • 19. PHP for Android: scripting PHP en Android The Android class public function rpc($method, $args) { $data = array( 'id'=>$this->_id, 'method'=>$method, 'params'=>$args ); $request = json_encode($data) . “n”; $sent = socket_write($this->_socket, $request, strlen($request));
  • 20. PHP for Android: scripting PHP en Android The Android class $response = socket_read($this->_socket, 1024, PHP_NORMAL_READ) or die("Could not read inputn"); $this->_id++; $result = json_decode($response); return array ('id' => $result->id, 'result' => $result->result, 'error' => $result->error ); }
  • 21. PHP for Android: scripting PHP en Android The Android class <?php require “Android.php”; $droid = new Android(); $droid->viewContacts();
  • 22. PHP for Android: scripting PHP en Android “WhereAmI” script ● Location. ● Email building (google maps link).
  • 23. PHP for Android: scripting PHP en Android “WhereAmI” script $droid->startLocating(); – Received: {"id":24,"method":"startLocating","params":[]} – Sent: {"error":null,"id":24,"result":null} $location = $droid->readLocation(); – Received: {"id":25,"method":"readLocation","params":[]} – Sent: {"error":null,"id":25,"result":{"network": {"provider":"network","time":1288215482448,"longitud e":- 3.0339431,"latitude":43.3319985,"speed":0,"accuracy" :76,"altitude":0}}}
  • 24. PHP for Android: scripting PHP en Android “WhereAmI” script $droid->stopLocating(); – Received: {"id":26,"method":"stopLocating","params":[]} – Sent: {"error":null,"id":26,"result":null} $longitude = $location["result"]->network->longitude; $latitude = $location["result"]->network->latitude; $mapLink = sprintf('http://maps.google.com/maps? q=%s,%s', $latitude, $longitude);
  • 25. PHP for Android: scripting PHP en Android “WhereAmI” script $data .= "Google maps : $mapLink"; $droid->sendEmail('', 'Donde estoy', $data ); – Received: {"id":29,"method":"sendEmail","params": ["","Donde estoy","admin_area : Pau00eds Vasco nfeature_name : 3 nsub_admin_area : Vizcaya npostal_code : 48980 nlocality : Santurtzi nthoroughfare : Calle del Puerto Pesquero ncountry_code : ES ncountry_name : Espau00f1a nnGoogle Maps: http://maps.google.com/maps? q=13.3319985, 6.0339431"]} – Sent: {"error":null,"id":29,"result":null}
  • 26. PHP for Android: scripting PHP en Android PFAf ● Maciej Wilgucki @wilgucki ● Framework avaiblable since PFA 0.3. ● Extend ScriptAbstract, implement init. ● Organize your script with states. ● function FooAction() { .... $this->setNextAction('bar');
  • 27. PHP for Android: scripting PHP en Android PFAf start locate credicts info
  • 28. PHP for Android: scripting PHP en Android Development environment ● SL4A... – Emulator, adb. ● [allow_url_fopen, allow_url_include] → ON – testnow.php – testcache.php ● Remote scripting.
  • 29. PHP for Android: scripting PHP en Android Script sharing ● SL4A scripts folder. ● Barcode (<4296 chars) ● Script on APK: – Template project → customize. – ANT
  • 30. PHP for Android: scripting PHP en Android Roadmap ● SL4A – API extended. ● GUI... – Bugfixes. ● PFA – Sqlite,... phpize. – supporting SL4A releases.
  • 31. PHP for Android: scripting PHP en Android ????? Questions Logo @Workoholics_