Non Conventional Android Programming (Italiano)

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Non Conventional Android Programming (Italiano) - Presentation Transcript

    1. Non-conventional Android Programming
    2. Chi sono? Davide Cerbo http://jesty.it http://davide.cerbo.born-to-co.de http://www.linkedin.com/in/davidecerbo [email_address]
    3. http://www.pro-netics.it [email_address]
    4. Prima bastava
    5. Nuove Caratteristiche
      • GPS
      • Bussola
      • Fotocamera
      • Schermi ad alta risoluzione
      • WI-FI
      • UMTS / HSPDA
      • Multi-touch
    6. Dove stiamo andando?
    7. (Il mercato)
    8. Troppi dispositivi
    9. Ad ognuno il suo
      • IPhone: Object C
      • Android: Java
      • BlackBerry: Java
      • Nokia/Symbian: Java e C++
      • Windows Mobile: .NET e C
    10. Write once, run anywhere Ricorda niente?
    11. PhoneGap HTML + JAVASCRIPT + CSS = PhoneGap.com
    12. PhoneGap CROSS PLATFORM + INTERFACCIA API NATIVE + OPEN SOURCE = PhoneGap.com
    13. Cosa posso fare? ...e a breve: fotocamera, mappe e gestione file
    14. 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 );
    15. 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 ; }
    16. 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/
    17. 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" ); }
    18. Perchè Android?
      • Open Source
      • Basato su Linux e Java (Dalvik)
      • Vasta scelta di dispositivi
      • Sistema operativo altamente personalizzabile
      ?
    19. Una piccola parentesi su Android 2.0 (Eclair)
      • Gestione di più Google account
      • 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...)
      • Messaggi SMS e MMS ricercabili
    20. MOTOROLA DROID http://droiddoes.com
    21. Ma Spring?
    22. SpringME
      • Permette l'utilizzo dell'object configuration tramite XML
      • Non utilizza la reflection, ma la generazione automatica del codice
      • Il pacchetto generato non conterrà librerie supplementari
      • Sviluppato e utilizzato da un Wilfred Springer, ex Software Architect in TomTom
      • Funziona tramite un plugin per Apache MAVEN
      • Nato per J2ME ma utilizzabile anche con GWT e Android
    23. SpringME: come funziona?
      • Spring utilizza la reflection per la 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”);
      • 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();
    24. Android + Maven
      • Installiamo l'SDK per Android
      • Impostiamo la variabile di ambiente ANDROID_SDK_15
      • 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
      • Creiamo un nuovo progetto, es.: android create project --target 3 --name MavenAndroidExample --path ./maven-android-example --activity MavenAndroidActivity --package it.jesty.mavenandroid.example
    25. Android + Maven
      • Creiamo il file pom.xml (lo vediamo nella prossima slide)
      • Facciamo un po' di pulizia: rm -r bin build.xml build.properties libs
      • Creiamo l'emulatore, es.: android create avd --name mavenandroidadv --target 3
      • Eseguiamo l'emulatore, es.: emulator -avd mavenandroidadv
      • mvn install per generare il file .apk
      • Eseguiamo il deploy del file .apk nel dispositivo: mvn com.jayway.maven.plugins.android.generation2:maven-android-plugin:deploy
    26. ... <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
    27.  
    28. Android + Maven + SpringME
      • Modifichiamo il pom.xml aggiungendo il plugin SpringME
      • 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>
      • Creiamo la classe Greeting.java
      • 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(...)); }
      • Ripetiamo il passo 8 e 9 mvn com.jayway.maven.plugins.android.generation2:maven-android-plugin:deploy
    29. ... <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> ...
    30. 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>
    31. 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; } }
    32.  
    33. Risorse e Bibliografia
      • Android http://www.android.com
      • PhoneGap http://phonegap.com
      • SpringME http://springframework.me http://sourceforge.net/projects/springme/
      • Libro su SpringME http://www.scribd.com/doc/8611209/Spring-ME
      • Maven per Android http://code.google.com/p/maven-android-plugin http://code.google.com/p/masa
      • Linee guida allo sviluppo per Android http://developer.android.com/guide/practices/design/performance.html
      • Big Picture degli store di Android, IPhone e IPod Touch http://mashable.com/2009/09/15/iphone-android-apps-visualized/
    34. Download esempi http://jesty.it/non-conventional-android-programming.zip Il file compresso contiene:
      • Esempio funzionante della demo di PhoneGap per Android
      • Esempio di utilizzo di Apache Maven con Android
      • Esempio di utilizzo di SpringME
    35.  
    36.  
    SlideShare Zeitgeist 2009

    + jestyjesty Nominate

    custom

    445 views, 1 favs, 1 embeds more stats

    Android è il nuovo sistema operativo open source p more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 445
      • 440 on SlideShare
      • 5 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 5
    Most viewed embeds
    • 5 views on http://pronetics.wordpress.com

    more

    All embeds
    • 5 views on http://pronetics.wordpress.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories