SlideShare a Scribd company logo
Non-conventional  Android  Programming
Who am I? Davide Cerbo http://jesty.it http://davide.cerbo.born-to-co.de http://www.linkedin.com/in/davidecerbo [email_address]
http://www.pro-netics.it [email_address]
Once upon a time...
New Features GPS
Compass
Camere
Hi-Res Screen
WI-FI
UMTS / HSPDA
Multi-touch
Where we going?
(market)
Too much devices
Many languages for many devices IPhone:  Objective C
Android:  Java
BlackBerry:  Java
Nokia/Symbian:  Java  e  C++
Windows Mobile:  .NET  e  C
Write once, run anywhere Do you remember?
PhoneGap HTML + JAVASCRIPT + CSS  = PhoneGap.com
PhoneGap CROSS PLATFORM + API NATIVE INTERFACES + OPEN SOURCE = PhoneGap.com
What I'm able to do? ...and coming soon: camera, maps and file manager
Examples //GEO REFERENCING var   getLocation   =   function ()   { var   suc   =   function ( p ){ alert ( p . coords . latitude   +   " "   +   p . coords . longitude ); }; var   fail   =   function (){ alert ( "Location not available!" );}; navigator . geolocation . getCurrentPosition ( suc , fail ,   undefined ); } //VIBRACALL navigator . notification . vibrate ( 0 ); //BEEEEEEP navigator . notification . beep ( 2 );
Examples //ACCELEROMETER var   watchAccel   =   function ()   { var   s   =   function ( a ){ document . getElementById ( 'x' ). innerHTML   =   roundNumber ( a . x ); document . getElementById ( 'y' ). innerHTML   =   roundNumber ( a . y ); document . getElementById ( 'z' ). innerHTML   =   roundNumber ( a . z ); }; var   d   =   function (){}; var   opt   =   {}; opt . frequency   =   100 ; Timer   =   navigator . accelerometer . watchAcceleration ( s , f , opt ); } //CAMERA navigator . camera . getPicture ( dump_pic ,   fail ,   {   quality :   50   }); function   dump_pic ( data) { ... document . getElementById ( "test" ). src = "data:image/jpeg;base64,"   +  data ; }
Where's the trick? PhoneGap give us a  startup project  for every supported device. Every project is a simple application made of a  web browser  that work as a fullscreen app and where javascripts object will be injected. These objects has native API counterpart inside the device. We need to copy html, css, javascript and images into a specific project folder for every device that we need to  deploy  on. We also need to modify the project configuration, like project's name, author and so on... For Android  copy  these files into: ../my-android/assets/www/
Just to explain... ...take a look at this piece of code extracted from DroidGap.java included in the Android startup project: private   void  bindBrowser(WebView appView) { gap  =  new  PhoneGap( this , appView); geo  =  new  GeoBroker(appView,  this ); accel  =  new  AccelListener( this , appView); launcher  =  new  CameraLauncher(appView,  this ); // This creates the new javascript interfaces for PhoneGap appView.addJavascriptInterface( gap ,  "DroidGap" ); appView.addJavascriptInterface( geo ,  "Geo" ); appView.addJavascriptInterface( accel ,  "Accel" ); appView.addJavascriptInterface( launcher ,  "GapCam" ); }
Why Android? Open Source
Linux and Java based (Dalvik)
So many Devices
OS highly customized ?
Android 2.0 (Eclair) in deep Multiple Google accounts management
Microsoft Excange Server support
Home, Menu and Back buttons become optional
New HTML5 web browser
Camera application improved (flash, digital zoom, etc...)

More Related Content

What's hot (17)

PDF
Avinash Kundaliya: Javascript and WordPress
wpnepal
 
PDF
Symfony 4 Workshop - Limenius
Ignacio Martín
 
ODP
Working With Canvas
Diogo Antunes
 
PDF
Boost your angular app with web workers
Enrique Oriol Bermúdez
 
PDF
Browsers with Wings
Remy Sharp
 
PPT
Sxsw 20090314
guestcabcf63
 
PPT
Google在Web前端方面的经验
yiditushe
 
PDF
Google App Engine in 40 minutes (the absolute essentials)
Python Ireland
 
ODP
Scti 2011 minicurso jquery
ciberglo
 
PDF
HTML5: where flash isn't needed anymore
Remy Sharp
 
PPTX
Fast by Default
Abhay Kumar
 
PDF
Your code are my tests
Michelangelo van Dam
 
PDF
Diseño y Desarrollo de APIs
Raúl Neis
 
PDF
Tips and tricks for building api heavy ruby on rails applications
Tim Cull
 
PDF
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
Frédéric Harper
 
PDF
QA for PHP projects
Michelangelo van Dam
 
PDF
How to build an AngularJS backend-ready app WITHOUT BACKEND
Enrique Oriol Bermúdez
 
Avinash Kundaliya: Javascript and WordPress
wpnepal
 
Symfony 4 Workshop - Limenius
Ignacio Martín
 
Working With Canvas
Diogo Antunes
 
Boost your angular app with web workers
Enrique Oriol Bermúdez
 
Browsers with Wings
Remy Sharp
 
Sxsw 20090314
guestcabcf63
 
Google在Web前端方面的经验
yiditushe
 
Google App Engine in 40 minutes (the absolute essentials)
Python Ireland
 
Scti 2011 minicurso jquery
ciberglo
 
HTML5: where flash isn't needed anymore
Remy Sharp
 
Fast by Default
Abhay Kumar
 
Your code are my tests
Michelangelo van Dam
 
Diseño y Desarrollo de APIs
Raúl Neis
 
Tips and tricks for building api heavy ruby on rails applications
Tim Cull
 
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
Frédéric Harper
 
QA for PHP projects
Michelangelo van Dam
 
How to build an AngularJS backend-ready app WITHOUT BACKEND
Enrique Oriol Bermúdez
 

Viewers also liked (18)

PPT
Quadraticfuntions
suefee
 
PPTX
Xman eng 20120419
Bassel Saab
 
PPT
Toward a Standardized XMAN Presentation Layer with Consideration of User Inte...
Bassel Saab
 
PPT
Quadraticequation
suefee
 
PPTX
Gei presentation -_malay
suefee
 
PPTX
Savanna Susquenita
Susquenita
 
DOC
Yearlylessonplanaddmathf42010
suefee
 
XLS
addmaths-gantt-chart-f4-and-5
suefee
 
PPT
La1 powerpoint-1
suefee
 
PDF
Ranadd math form_5yearplan2009
suefee
 
PPT
Quadraticfuntions
suefee
 
PPT
Functions
suefee
 
DOC
Yearly plan add maths f52010
suefee
 
XLS
Carta gantt-add-math-f4
suefee
 
PPT
Simultaneous equations
suefee
 
DOC
37756909 yearly-plan-add-maths-form-4-edit-kuching-1
suefee
 
DOCX
Daily lesson plan ict form 5
suefee
 
Quadraticfuntions
suefee
 
Xman eng 20120419
Bassel Saab
 
Toward a Standardized XMAN Presentation Layer with Consideration of User Inte...
Bassel Saab
 
Quadraticequation
suefee
 
Gei presentation -_malay
suefee
 
Savanna Susquenita
Susquenita
 
Yearlylessonplanaddmathf42010
suefee
 
addmaths-gantt-chart-f4-and-5
suefee
 
La1 powerpoint-1
suefee
 
Ranadd math form_5yearplan2009
suefee
 
Quadraticfuntions
suefee
 
Functions
suefee
 
Yearly plan add maths f52010
suefee
 
Carta gantt-add-math-f4
suefee
 
Simultaneous equations
suefee
 
37756909 yearly-plan-add-maths-form-4-edit-kuching-1
suefee
 
Daily lesson plan ict form 5
suefee
 
Ad

Similar to Non Conventional Android Programming En (20)

PDF
JavaScript APIs - The Web is the Platform
Robert Nyman
 
PPTX
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Jim Tochterman
 
PPTX
Client-side JavaScript Vulnerabilities
Ory Segal
 
PPTX
Phone Gap
Yiguang Hu
 
PPT
Developing in android
Christopher Decker
 
PDF
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
PDF
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
PDF
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
PDF
HTML5: huh, what is it good for?
Remy Sharp
 
PDF
Phone gap 12 things you should know
ISOCHK
 
PDF
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
Wim Selles
 
ODP
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
PPT
Dojo and Adobe AIR
Nikolai Onken
 
PPTX
CiklumJavaSat_15112011:Alex Kruk VMForce
Ciklum Ukraine
 
PDF
mobl
zefhemel
 
PPTX
Django + Vue, JavaScript de 3ª generación para modernizar Django
Javier Abadía
 
PDF
Android Best Practices
Yekmer Simsek
 
PPT
21 android2 updated
GhanaGTUG
 
PDF
Having Fun with Play
Clinton Dreisbach
 
ODP
Pyramid Lighter/Faster/Better web apps
Dylan Jay
 
JavaScript APIs - The Web is the Platform
Robert Nyman
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Jim Tochterman
 
Client-side JavaScript Vulnerabilities
Ory Segal
 
Phone Gap
Yiguang Hu
 
Developing in android
Christopher Decker
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
HTML5: huh, what is it good for?
Remy Sharp
 
Phone gap 12 things you should know
ISOCHK
 
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
Wim Selles
 
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
Dojo and Adobe AIR
Nikolai Onken
 
CiklumJavaSat_15112011:Alex Kruk VMForce
Ciklum Ukraine
 
mobl
zefhemel
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Javier Abadía
 
Android Best Practices
Yekmer Simsek
 
21 android2 updated
GhanaGTUG
 
Having Fun with Play
Clinton Dreisbach
 
Pyramid Lighter/Faster/Better web apps
Dylan Jay
 
Ad

Recently uploaded (20)

PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 

Non Conventional Android Programming En

  • 2. Who am I? Davide Cerbo http://jesty.it http://davide.cerbo.born-to-co.de http://www.linkedin.com/in/davidecerbo [email_address]
  • 4. Once upon a time...
  • 15. Many languages for many devices IPhone: Objective C
  • 19. Windows Mobile: .NET e C
  • 20. Write once, run anywhere Do you remember?
  • 21. PhoneGap HTML + JAVASCRIPT + CSS = PhoneGap.com
  • 22. PhoneGap CROSS PLATFORM + API NATIVE INTERFACES + OPEN SOURCE = PhoneGap.com
  • 23. What I'm able to do? ...and coming soon: camera, maps and file manager
  • 24. Examples //GEO REFERENCING var getLocation = function () { var suc = function ( p ){ alert ( p . coords . latitude + " " + p . coords . longitude ); }; var fail = function (){ alert ( "Location not available!" );}; navigator . geolocation . getCurrentPosition ( suc , fail , undefined ); } //VIBRACALL navigator . notification . vibrate ( 0 ); //BEEEEEEP navigator . notification . beep ( 2 );
  • 25. Examples //ACCELEROMETER var watchAccel = function () { var s = function ( a ){ document . getElementById ( 'x' ). innerHTML = roundNumber ( a . x ); document . getElementById ( 'y' ). innerHTML = roundNumber ( a . y ); document . getElementById ( 'z' ). innerHTML = roundNumber ( a . z ); }; var d = function (){}; var opt = {}; opt . frequency = 100 ; Timer = navigator . accelerometer . watchAcceleration ( s , f , opt ); } //CAMERA navigator . camera . getPicture ( dump_pic , fail , { quality : 50 }); function dump_pic ( data) { ... document . getElementById ( "test" ). src = "data:image/jpeg;base64," + data ; }
  • 26. Where's the trick? PhoneGap give us a startup project for every supported device. Every project is a simple application made of a web browser that work as a fullscreen app and where javascripts object will be injected. These objects has native API counterpart inside the device. We need to copy html, css, javascript and images into a specific project folder for every device that we need to deploy on. We also need to modify the project configuration, like project's name, author and so on... For Android copy these files into: ../my-android/assets/www/
  • 27. Just to explain... ...take a look at this piece of code extracted from DroidGap.java included in the Android startup project: private void bindBrowser(WebView appView) { gap = new PhoneGap( this , appView); geo = new GeoBroker(appView, this ); accel = new AccelListener( this , appView); launcher = new CameraLauncher(appView, this ); // This creates the new javascript interfaces for PhoneGap appView.addJavascriptInterface( gap , "DroidGap" ); appView.addJavascriptInterface( geo , "Geo" ); appView.addJavascriptInterface( accel , "Accel" ); appView.addJavascriptInterface( launcher , "GapCam" ); }
  • 29. Linux and Java based (Dalvik)
  • 32. Android 2.0 (Eclair) in deep Multiple Google accounts management
  • 34. Home, Menu and Back buttons become optional
  • 35. New HTML5 web browser
  • 36. Camera application improved (flash, digital zoom, etc...)
  • 37. SMS and MMS are now searchable
  • 41. No reflection needed, auto-code generation
  • 42. The final package does not contain extra libraries
  • 43. Developed and maintained by Wilfred Springer, ex Tom Tom Software Architect
  • 45. Designed for J2ME but also suitable for GWT and Android
  • 46. SpringME: how does it works? Spring use reflection for Dependency Injection Class cl = Class.forName("Person"); Object instance = cl.newInstance(); Method meth = cl.getDeclaredMethod("setName"); method.invoke(instance, new Object[] { "Nick Hornby" }); --------------------------------------------------------- ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(...); BeanFactory factory = (BeanFactory) appContext; Person frank = (Person)factory.getBean(“frank”);
  • 47. SpringME produce the code through the Apache Maven plugin Person instance = new Person(); instance.setName("Wilfred Springer"); --------------------------------------------------------- BeanFactory factory = new BeanFactory(); Person frank1 = (Person)factory.getBean(“frank”); Person frank2 = factory.getFrank();
  • 48. Android + Maven Install the Android SDK
  • 49. Setup the env variable ANDROID_SDK_15
  • 50. Install Android into our maven repository , for example: mvn install:install-file -DgroupId=android -DartifactId=android -Dversion=1.5_r2 -Dpackaging=jar -Dfile=$ANDROID_SDK_15/platforms/android-1.5/android.jar
  • 51. Let's create a brand new project: android create project --target 3 --name MavenAndroidExample --path ./maven-android-example --activity MavenAndroidActivity --package it.jesty.mavenandroid.example
  • 52. Android + Maven Create a pom.xml file (we'll see it in the next slide)
  • 53. Let's clean up the mess: rm -r bin build.xml build.properties libs
  • 54. Create the emulator: android create avd --name mavenandroidadv --target 3
  • 55. Execute the emulator: emulator -avd mavenandroidadv
  • 56. Create our package with: mvn install (.apk file)
  • 57. Let's deploy the .apk into our device: mvn com.jayway.maven.plugins.android.generation2:maven-android-plugin:deploy
  • 58. ... <dependencies> <dependency> <groupId> android </groupId> <artifactId> android </artifactId> <version> 1.5_r2 </version> <scope> provided </scope> </dependency> </dependencies> <build> <sourceDirectory> src </sourceDirectory> <plugins> <plugin> <groupId> com.jayway.maven.plugins.android.generation2 </groupId> <artifactId> maven-android-plugin </artifactId> <version> 2.1.0 </version> <configuration> <sdk> <path> ${env.ANDROID_SDK_15} </path> <platform> 1.5 </platform> </sdk> <deleteConflictingFiles> True </deleteConflictingFiles> </configuration> <extensions> true </extensions> </plugin> ... Android + Maven
  • 59.  
  • 60. Android + Maven + SpringME Modify the pom.xml adding the SpringME plugin
  • 61. Create the application-context.xml into /context: <beans> <bean id=&quot;ciao&quot; class=&quot;it.jesty....Greeting&quot; scope=&quot;prototype&quot;> <constructor-arg value=&quot;Ciao&quot; /> </bean> </beans>
  • 63. Modify the MavenAndroidActivity.java: public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); TextView tv = new TextView( this ); tv.setText(((Greeting)new BeanFactory().getBean( &quot;ciao&quot; )) .to( &quot;MavenAndroidActivity&quot; )); //oppure: tv.setText(((Greeting)new BeanFactory().getCiao()).to(...)); }
  • 64. Repeat 8 and 9 steps mvn com.jayway.maven.plugins.android.generation2:maven-android-plugin:deploy
  • 65. ... <resources> <resource> <directory>${basedir}/context/</directory> <filtering>true</filtering> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory> ${basedir}/target/generated-sources/spring-me </directory> </resource> </resources> <plugins> <plugin> <groupId>me.springframework</groupId> <artifactId>spring-me-maven-plugin</artifactId> <version>1.0-SNAPSHOT</version> <executions> <execution> <goals> <goal>generate</goal> <goal>dot</goal> </goals> <phase>generate-sources</phase> </execution> </executions> <configuration> <contextFile> ${basedir}/context/application-context.xml </contextFile> <className> it.jesty.mavenandroid.example.BeanFactory </className> <dotFile>${basedir}/target/poloko-context.dot</dotFile> </configuration> </plugin> ...
  • 66. Android + Maven + SpringME <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <beans xmlns=&quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot; http://www.springframework.org/schema /beans http://www.springframework.org/schema/beans/spring- beans-2.0.xsd&quot; default-lazy-init=&quot;true&quot; > <bean id=&quot;ciao&quot; class=&quot;it.jesty...Greeting&quot; scope=&quot;prototype&quot; > <constructor-arg value=&quot;Ciao&quot; /> </bean> <bean id=&quot;hello&quot; class=&quot;it.jest...Greeting&quot; scope=&quot;prototype&quot; > <constructor-arg value=&quot;Hello&quot; /> </bean> </beans>
  • 67. Android + Maven + SpringME package it.jesty.mavenandroid.example; public class Greeting { private String greeting; public Greeting(String greeting){ this .greeting = greeting; } public String to(String to){ return this .greeting + &quot;, &quot; + to; } }
  • 68.  
  • 69. Links and resources: Android http://www.android.com
  • 73. Maven for Android http://code.google.com/p/maven-android-plugin http://code.google.com/p/masa
  • 74. Android development guidelines http://developer.android.com/guide/practices/design/performance.html
  • 75. Android, IPhone and IPod Touch Big Picture http://mashable.com/2009/09/15/iphone-android-apps-visualized/
  • 77. Apache Maven for Android examples
  • 78. SpringME examples ...all fully functional !!! :)
  • 79.  
  • 80.