SlideShare a Scribd company logo
1 of 36
Non-conventional  Android  Programming
Chi sono? 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]
Prima bastava
Nuove Caratteristiche ,[object Object]
Bussola
Fotocamera
Schermi ad alta risoluzione
WI-FI
UMTS / HSPDA
Multi-touch
Dove stiamo andando?
(Il mercato)
Troppi dispositivi
Ad ognuno il suo ,[object Object]
Android:  Java
BlackBerry:  Java
Nokia/Symbian:  Java  e  C++
Windows Mobile:  .NET  e  C
Write once, run anywhere Ricorda niente?
PhoneGap HTML + JAVASCRIPT + CSS  = PhoneGap.com
PhoneGap CROSS PLATFORM + INTERFACCIA API NATIVE + OPEN SOURCE = PhoneGap.com
Cosa posso fare? ...e a breve: fotocamera, mappe e gestione file
Esempi assortiti //LOCALIZZAZIONE GEOGRAFICA 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 ); } //VIBRAZIONE navigator . notification . vibrate ( 0 ); //BEEEEEEP navigator . notification . beep ( 2 );
Esempi assortiti //ACCELLEROMETRO 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 ); } //FOTOCAMERA navigator . camera . getPicture ( dump_pic ,   fail ,   {   quality :   50   }); function   dump_pic ( data) { ... document . getElementById ( "test" ). src = "data:image/jpeg;base64,"   +  data ; }
Dove è il trucco? PhoneGap mette a disposizione un  progetto di partenza  per ogni dispositivo supportato. Ogni progetto è una semplice applicazione costituita da un  browser web  che gira a tutto schermo ed in cui sono state iniettate degli oggetti javascript che corrispondono alle API native del dispositivo. Per ogni dispositivo per cui vogliamo  distribuire  il nostro applicativo dovremmo copiare i file html, css, javascript e le immagini dentro una cartella del progetto e modificare le configurazioni necessarie, ad esempio il nome del progetto, l'autore, etc.. Nel caso di Android dovremmo  copiare  i file in: ../my-android/assets/www/
Per capirci meglio... ...osserviamo questo pezzo di codice tratto dalla classe DroidGap.java contenuta nel progetto di partenza per Android: 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" ); }
Perchè Android? ,[object Object]
Basato su Linux e Java (Dalvik)
Vasta scelta di dispositivi
Sistema operativo altamente personalizzabile ?
Una piccola parentesi su  Android 2.0 (Eclair) ,[object Object]
Supporto per Microsoft Excange Server
Pulsanti Home, Menu e Back diventano facoltativi
Nuovo browser web con HTML5
Migliorata applicazione della fotocamera (flash, zoom digitale, etc...)

More Related Content

Similar to Non Conventional Android Programming (Italiano)

JAMP DAY 2010 - ROMA (3)
JAMP DAY 2010 - ROMA (3)JAMP DAY 2010 - ROMA (3)
JAMP DAY 2010 - ROMA (3)jampslide
 
Rich Ajax Web Interfaces in Jquery
Rich Ajax Web Interfaces in JqueryRich Ajax Web Interfaces in Jquery
Rich Ajax Web Interfaces in JqueryAlberto Buschettu
 
Primo Incontro Con Scala
Primo Incontro Con ScalaPrimo Incontro Con Scala
Primo Incontro Con ScalaFranco Lombardo
 
jQuery e i suoi plugin
jQuery e i suoi pluginjQuery e i suoi plugin
jQuery e i suoi pluginPasquale Puzio
 
Dominare il codice legacy
Dominare il codice legacyDominare il codice legacy
Dominare il codice legacyTommaso Torti
 
Programmare Google Maps con Javascript
Programmare Google Maps con JavascriptProgrammare Google Maps con Javascript
Programmare Google Maps con Javascriptextrategy
 
Sviluppo e deployment cross-platform: Dal mobile alla Tv
Sviluppo e deployment cross-platform: Dal mobile alla Tv Sviluppo e deployment cross-platform: Dal mobile alla Tv
Sviluppo e deployment cross-platform: Dal mobile alla Tv Codemotion
 
Creazione componenti con Vue js
Creazione componenti con Vue jsCreazione componenti con Vue js
Creazione componenti con Vue jsGianfranco Castro
 
Marco Rho: Magento theme development workflow con Grunt
Marco Rho: Magento theme development workflow con GruntMarco Rho: Magento theme development workflow con Grunt
Marco Rho: Magento theme development workflow con GruntMeet Magento Italy
 
Android Widget @ whymca 2011
Android Widget @ whymca 2011Android Widget @ whymca 2011
Android Widget @ whymca 2011Fabio Collini
 
Working between the clouds
Working between the cloudsWorking between the clouds
Working between the cloudsDavide Cerbo
 
DrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache Cordova
DrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache CordovaDrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache Cordova
DrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache CordovaDrupalDay
 
01 Android - Introduction
01   Android - Introduction01   Android - Introduction
01 Android - Introductionspawn150
 

Similar to Non Conventional Android Programming (Italiano) (20)

JAMP DAY 2010 - ROMA (3)
JAMP DAY 2010 - ROMA (3)JAMP DAY 2010 - ROMA (3)
JAMP DAY 2010 - ROMA (3)
 
Rich Ajax Web Interfaces in Jquery
Rich Ajax Web Interfaces in JqueryRich Ajax Web Interfaces in Jquery
Rich Ajax Web Interfaces in Jquery
 
Pycon Jungle
Pycon JunglePycon Jungle
Pycon Jungle
 
Primo Incontro Con Scala
Primo Incontro Con ScalaPrimo Incontro Con Scala
Primo Incontro Con Scala
 
jQuery e i suoi plugin
jQuery e i suoi pluginjQuery e i suoi plugin
jQuery e i suoi plugin
 
Dominare il codice legacy
Dominare il codice legacyDominare il codice legacy
Dominare il codice legacy
 
Sinfonia in Domino RE - Integrazione Symphony e Lotus Notes 8.x
Sinfonia in Domino RE - Integrazione Symphony e Lotus Notes 8.xSinfonia in Domino RE - Integrazione Symphony e Lotus Notes 8.x
Sinfonia in Domino RE - Integrazione Symphony e Lotus Notes 8.x
 
Programmare Google Maps con Javascript
Programmare Google Maps con JavascriptProgrammare Google Maps con Javascript
Programmare Google Maps con Javascript
 
Sviluppo e deployment cross-platform: Dal mobile alla Tv
Sviluppo e deployment cross-platform: Dal mobile alla Tv Sviluppo e deployment cross-platform: Dal mobile alla Tv
Sviluppo e deployment cross-platform: Dal mobile alla Tv
 
#dd12 grillo daniele_xpages_tips_tricks_rev2
#dd12 grillo daniele_xpages_tips_tricks_rev2#dd12 grillo daniele_xpages_tips_tricks_rev2
#dd12 grillo daniele_xpages_tips_tricks_rev2
 
XPages Tips & Tricks, #dd13
XPages Tips & Tricks, #dd13XPages Tips & Tricks, #dd13
XPages Tips & Tricks, #dd13
 
Creazione componenti con Vue js
Creazione componenti con Vue jsCreazione componenti con Vue js
Creazione componenti con Vue js
 
Marco Rho: Magento theme development workflow con Grunt
Marco Rho: Magento theme development workflow con GruntMarco Rho: Magento theme development workflow con Grunt
Marco Rho: Magento theme development workflow con Grunt
 
Android Widget @ whymca 2011
Android Widget @ whymca 2011Android Widget @ whymca 2011
Android Widget @ whymca 2011
 
Working between the clouds
Working between the cloudsWorking between the clouds
Working between the clouds
 
Ivano brogonzoli why_mca
Ivano brogonzoli why_mcaIvano brogonzoli why_mca
Ivano brogonzoli why_mca
 
Js intro
Js introJs intro
Js intro
 
DrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache Cordova
DrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache CordovaDrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache Cordova
DrupalGap: crea una app Android (ed iOS) con Drupal, Drupalgap ed Apache Cordova
 
Applicazioni native in java
Applicazioni native in javaApplicazioni native in java
Applicazioni native in java
 
01 Android - Introduction
01   Android - Introduction01   Android - Introduction
01 Android - Introduction
 

More from Davide Cerbo

Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Davide Cerbo
 
Kotlin: maybe it's the right time
Kotlin: maybe it's the right timeKotlin: maybe it's the right time
Kotlin: maybe it's the right timeDavide Cerbo
 
From 0 to React with ES6 and Tests
From 0 to React with ES6 and TestsFrom 0 to React with ES6 and Tests
From 0 to React with ES6 and TestsDavide Cerbo
 
Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)Davide Cerbo
 
Working between the clouds (versione completa)
Working between the clouds (versione completa)Working between the clouds (versione completa)
Working between the clouds (versione completa)Davide Cerbo
 
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...Davide Cerbo
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Davide Cerbo
 

More from Davide Cerbo (8)

Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
 
Kotlin: maybe it's the right time
Kotlin: maybe it's the right timeKotlin: maybe it's the right time
Kotlin: maybe it's the right time
 
From 0 to React with ES6 and Tests
From 0 to React with ES6 and TestsFrom 0 to React with ES6 and Tests
From 0 to React with ES6 and Tests
 
Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)
 
Di cosa parlano?
Di cosa parlano?Di cosa parlano?
Di cosa parlano?
 
Working between the clouds (versione completa)
Working between the clouds (versione completa)Working between the clouds (versione completa)
Working between the clouds (versione completa)
 
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 

Non Conventional Android Programming (Italiano)

  • 2. Chi sono? Davide Cerbo http://jesty.it http://davide.cerbo.born-to-co.de http://www.linkedin.com/in/davidecerbo [email_address]
  • 5.
  • 8. Schermi ad alta risoluzione
  • 15.
  • 19. Windows Mobile: .NET e C
  • 20. Write once, run anywhere Ricorda niente?
  • 21. PhoneGap HTML + JAVASCRIPT + CSS = PhoneGap.com
  • 22. PhoneGap CROSS PLATFORM + INTERFACCIA API NATIVE + OPEN SOURCE = PhoneGap.com
  • 23. Cosa posso fare? ...e a breve: fotocamera, mappe e gestione file
  • 24. Esempi assortiti //LOCALIZZAZIONE GEOGRAFICA 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 ); } //VIBRAZIONE navigator . notification . vibrate ( 0 ); //BEEEEEEP navigator . notification . beep ( 2 );
  • 25. Esempi assortiti //ACCELLEROMETRO 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 ); } //FOTOCAMERA navigator . camera . getPicture ( dump_pic , fail , { quality : 50 }); function dump_pic ( data) { ... document . getElementById ( "test" ). src = "data:image/jpeg;base64," + data ; }
  • 26. Dove è il trucco? PhoneGap mette a disposizione un progetto di partenza per ogni dispositivo supportato. Ogni progetto è una semplice applicazione costituita da un browser web che gira a tutto schermo ed in cui sono state iniettate degli oggetti javascript che corrispondono alle API native del dispositivo. Per ogni dispositivo per cui vogliamo distribuire il nostro applicativo dovremmo copiare i file html, css, javascript e le immagini dentro una cartella del progetto e modificare le configurazioni necessarie, ad esempio il nome del progetto, l'autore, etc.. Nel caso di Android dovremmo copiare i file in: ../my-android/assets/www/
  • 27. Per capirci meglio... ...osserviamo questo pezzo di codice tratto dalla classe DroidGap.java contenuta nel progetto di partenza per Android: 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" ); }
  • 28.
  • 29. Basato su Linux e Java (Dalvik)
  • 30. Vasta scelta di dispositivi
  • 31. Sistema operativo altamente personalizzabile ?
  • 32.
  • 33. Supporto per Microsoft Excange Server
  • 34. Pulsanti Home, Menu e Back diventano facoltativi
  • 35. Nuovo browser web con HTML5
  • 36. Migliorata applicazione della fotocamera (flash, zoom digitale, etc...)
  • 37. Messaggi SMS e MMS ricercabili
  • 40.
  • 41. Non utilizza la reflection, ma la generazione automatica del codice
  • 42. Il pacchetto generato non conterrà librerie supplementari
  • 43. Sviluppato e utilizzato da un Wilfred Springer, ex Software Architect in TomTom
  • 44. Funziona tramite un plugin per Apache MAVEN
  • 45. Nato per J2ME ma utilizzabile anche con GWT e Android
  • 46.
  • 47. SpringME genera automaticamente il codice tramite un plugin per Apache Maven Person instance = new Person(); instance.setName("Wilfred Springer"); --------------------------------------------------------- BeanFactory factory = new BeanFactory(); Person frank1 = (Person)factory.getBean(“frank”); Person frank2 = factory.getFrank();
  • 48.
  • 49. Impostiamo la variabile di ambiente ANDROID_SDK_15
  • 50. Installiamo Android nel nostro repository , es.: 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. Creiamo un nuovo progetto, es.: android create project --target 3 --name MavenAndroidExample --path ./maven-android-example --activity MavenAndroidActivity --package it.jesty.mavenandroid.example
  • 52.
  • 53. Facciamo un po' di pulizia: rm -r bin build.xml build.properties libs
  • 54. Creiamo l'emulatore, es.: android create avd --name mavenandroidadv --target 3
  • 55. Eseguiamo l'emulatore, es.: emulator -avd mavenandroidadv
  • 56. mvn install per generare il file .apk
  • 57. Eseguiamo il deploy del file .apk nel dispositivo: 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.
  • 61. Creiamo il file application-context.xml in /context, es.: <beans> <bean id=&quot;ciao&quot; class=&quot;it.jesty....Greeting&quot; scope=&quot;prototype&quot;> <constructor-arg value=&quot;Ciao&quot; /> </bean> </beans>
  • 62. Creiamo la classe Greeting.java
  • 63. Modifichiamo la classe MavenAndroidActivity.java, es.: 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. Ripetiamo il passo 8 e 9 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.
  • 72. Libro su SpringME http://www.scribd.com/doc/8611209/Spring-ME
  • 73. Maven per Android http://code.google.com/p/maven-android-plugin http://code.google.com/p/masa
  • 74. Linee guida allo sviluppo per Android http://developer.android.com/guide/practices/design/performance.html
  • 75. Big Picture degli store di Android, IPhone e IPod Touch http://mashable.com/2009/09/15/iphone-android-apps-visualized/
  • 76.
  • 77. Esempio di utilizzo di Apache Maven con Android
  • 78. Esempio di utilizzo di SpringME
  • 79.  
  • 80.