SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
Native Android Development with Spring

Roy Clarkson
Spring Mobile Projects Lead
SpringSource, a division of VMware
@royclarkson
@springandroid




                                     © 2010 SpringSource, A division of VMware. All rights reserved
                                       2012
Introduction

§ What are the purposes of the Spring for Android
 and Spring Mobile projects?

 • Spring for Android provides support for building native
  Android applications utilizing Spring technologies, where
  applicable.

 • In contrast, Spring Mobile provides support for building
  mobile web applications.




                             CONFIDENTIAL
                                                              2
Spring for Android
 • Android Overview
 • Define the Problem
 • Review of REST
 • Basic Rest Template Example
 • Rest Template Overview
 • Maven Can Help
 • Showcase and Demos
 • Questions



                        CONFIDENTIAL
                                       3
Android Adoption

§ Year-on-year growth rate of more than 250%
§ 850,000 new Android devices are activated each day
§ Over 300 million devices around the world
§ Over 450,000 apps available in Google Play
§ Over 1 billion app downloads per month




 http://googlemobile.blogspot.com/2012/02/androidmobile-world-congress-its-all.html

                                      CONFIDENTIAL
                                                                                      4
Android Fragmentation

§ Current Distribution
 • Gingerbread 62%
 • Froyo 25.3%
 • Eclair 6.6%
 • Honeycomb 3.3%
 • Ice Cream
   Sandwich 1.6%




 http://developer.android.com/resources/dashboard/platform-versions.html

                                 CONFIDENTIAL
                                                                           5
Android is Familiar




            Applications are written in Java!
                      (well, sort of)




                         CONFIDENTIAL
                                                6
But not that Familiar...


§ Class Files
 • Android apps are compiled to class files.

§ DEX Format
 • Classes are compiled into the Dalvik Executable (DEX) format.
 • DEX format is required to run on the Dalvik Virtual Machine.

§ Dalvik VM
 • Not a true Java VM, because it does not operate on Java byte code.
 • Based on a subset of the Apache Harmony project.
 • Many of the classes from Java SE are available, but not all.


                                CONFIDENTIAL
                                                                        7
Isolation of an App


§ Unique Linux User ID
   • Android OS assigns each app a unique Linux user ID.

§ Process Isolation
   • Within the VM, each app runs in its own Linux process.

§ Managed Lifecycle
   • The system manages the starting and stopping.




                            CONFIDENTIAL
                                                              8
Components of an Android App

§ Activities - An activity represents a single screen with a
 user interface.

§ Services - A service is a component that runs in the
 background to perform long-running operations or to
 perform work for remote processes.

§ Content Providers - A content provider manages a
 shared set of application data.

§ Broadcast Receivers - A broadcast receiver is a
 component that responds to system-wide broadcast
 announcements.

     http://developer.android.com/guide/topics/fundamentals.html

                                CONFIDENTIAL
                                                                   9
Android Manifest


§ contains the permissions requested by the app
§ Lists all of the components of an app

<uses-sdk android:minSdkVersion="10" />
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".HelloAndroidActivity"
        android:label="@string/app_name" >
        <intent-filter>
             <action android:name="android.intent.action.MAIN" />
             <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>




                                   CONFIDENTIAL
                                                                            10
A simple Activity



package org.springsource;

import android.app.Activity;
import android.os.Bundle;

public class HelloAndroidActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}




                               CONFIDENTIAL
                                                        11
STS and the ADT Plugin for Eclipse



                      HelloAndroid Demo




     http://www.springsource.org/springsource-tool-suite-download

           http://developer.android.com/sdk/eclipse-adt.html

                                CONFIDENTIAL
                                                                    12
How can Maven help?
§ Android4Maven
 • This project compiles android.jar from source and pulls out
   source and resource files to replicate android.jar in the SDK
 • http://sourceforge.net/projects/android4maven/

§ Maven Android SDK Deployer
 • If you need to use Google maps, then you have to go this
   route
 • https://github.com/mosabua/maven-android-sdk-deployer

§ Android Maven Plugin
 • Provides support for Maven dependency management within
   Android projects
 • http://code.google.com/p/maven-android-plugin/

                              CONFIDENTIAL
                                                                   13
Android Maven Plugin Configuration


<packaging>apk</packaging>



<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>3.1.1</version>
    <configuration>
         <sdk>
             <platform>${android-platform}</platform>
         </sdk>
         <deleteConflictingFiles>true</deleteConflictingFiles>
         <undeployBeforeDeploy>true</undeployBeforeDeploy>
    </configuration>
    <extensions>true</extensions>
</plugin>



https://repository.sonatype.org/index.html#nexus-search;quick~com.google.android

                                    CONFIDENTIAL
                                                                               14
Maven Commands

Build your Android App
$ mvn clean install


Start the Emulator
$ mvn android:emulator-start


Deploy the app to the emulator
$ mvn android:deploy


Run the app
$ mvn android:run




  http://maven-android-plugin-m2site.googlecode.com/svn/plugin-info.html

                                 CONFIDENTIAL
                                                                           15
Maven Demo




   CONFIDENTIAL
                  16
m2eclipse Support


§ Android Configurator for M2E Maven Integration for Eclipse
 • An Eclipse plugin that adds support for integrating m2eclipse, Android
   Developer Tools, and the Android Maven Plugin
 • http://rgladwell.github.com/m2e-android/

§ Maven Android archetypes
 • This project provides several Maven archetypes for Android. These
   archetypes allow you to quickly bootstrap a Maven project to develop an
   android application.
 • https://github.com/akquinet/android-archetypes




                                  CONFIDENTIAL
                                                                            17
This sounds too good!




                        @rgladwell

                          CONFIDENTIAL
                                         18
Spring for Android




       CONFIDENTIAL
                      19
What problem are we trying to solve?


§ Concerns
 • REST has become a popular choice for architecting both public
   and private web services
 • The Android runtime provides HTTP clients capable of making
   HTTP connections and requests, but it does not have a fully
   featured REST client

§ Spring for Android Solution
 • The goal of Spring for Android Rest Template is to provide an
  easy to use, and functional REST client that supports marshaling
  objects from XML and JSON.




                               CONFIDENTIAL
                                                                   20
REST

§ Origin
 • The term Representational State Transfer was introduced and
   defined in 2000 by Roy Fielding in his doctoral dissertation.

§ His paper suggests these four design principles:
 • Use HTTP methods explicitly.
   • POST, GET, PUT, DELETE
   • CRUD operations can be mapped to these existing methods
 • Be stateless.
   • State dependencies limit or restrict scalability
 • Expose directory structure-like URIs.
   • URI’s should be easily understood
 • Transfer XML, JavaScript Object Notation (JSON), or both.
   • Use XML or JSON to represent data objects or attributes


                                CONFIDENTIAL
                                                                   21
Basic Rest Template Example


§ Google search example
RestTemplate restTemplate = new RestTemplate();
String url =
"https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}";
String result = restTemplate.getForObject(url, String.class, "SpringSource");




§ Multiple parameters example
RestTemplate restTemplate = new RestTemplate();
String url = "http://example.com/hotels/{hotel}/bookings/{booking}";
String result = restTemplate.getForObject(url, String.class, "42", “21”);




                                    CONFIDENTIAL
                                                                                22
Google Search Demo




       CONFIDENTIAL
                      23
Spring for Android Rest Template


§ Based on SpringFramework
 • Originated as a fork of RestTemplate from SpringFramework.
 • Modifications were made to support Android.

§ RestTemplate class is the heart of the library
 • Entry points for the six main HTTP methods
   • DELETE - delete(...)
   • GET - getForObject(...)
   • HEAD - headForHeaders(...)
   • OPTIONS - optionsForAllow(...)
   • POST - postForLocation(...)
   • PUT - put(...)
   • any HTTP operation - exchange(...) and execute(...)

                                 CONFIDENTIAL
                                                                24
HTTP Clients


§ SimpleClientHttpRequestFactory
 • Delegates to the standard J2SE facilities

§ HttpComponentsClientHttpRequestFactory
 • Delegates to the native HttpComponents HttpClient

§ CommonsClientHttpRequestFactory (deprecated)
 • Delegates to the Commons HttpClient which is not native to Android




                                CONFIDENTIAL
                                                                    25
Message Converters


§ MappingJacksonHttpMessageConverter
 • object to JSON marshaling supported via the Jackson JSON Processor


§ SimpleXmlHttpMessageConverter
 • object to XML marshaling supported via the Simple XML Serializer


§ SyndFeedHttpMessageConverter
 • RSS and Atom feeds supported via the Android ROME Feed Reader




                                CONFIDENTIAL
                                                                      26
Spring for Android Showcase

§ Examples
 • HTTP GET
   • JSON
   • XML
 • HTTP GET with Parameters
   • JSON
   • XML
 • HTTP POST
   •   String
   •   JSON
   •   XML
   •   MultiValueMap
 • RSS
 • ATOM


                              CONFIDENTIAL
                                             27
Rest Template Demos




       CONFIDENTIAL
                      28
Spring Social on Android


§ What is Spring Social?
 • Spring Social is an extension of the Spring Framework that allows you to
   connect your applications with Software-as-a-Service (SaaS) providers such as
   Facebook and Twitter.


§ How does it relate to Spring for Android?
 • Utilizes RestTemplate to make RESTful requests to providers.

§ How can Spring for Android help?
 • Auth library in Spring for Android provides a SQLiteConnectionRepository for
   use with Spring Social.




                                     CONFIDENTIAL
                                                                                  29
Additional Resources

§ Slides:
  • http://portal.sliderocket.com/vmware/Native-Android-Development-with-Spring
§ Project Home:
  • http://www.springsource.org/spring-android
§ Sample Code:
  • https://github.com/SpringSource/spring-android-samples
§ Webinar:
  • http://www.springsource.org/node/3505
§ Blog Posts:
  • http://blog.springsource.com/author/rclarkson/




                                      CONFIDENTIAL
                                                                                  30

Más contenido relacionado

La actualidad más candente

Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentJustin James
 
Developing Hybrid Applications with IONIC
Developing Hybrid Applications with IONICDeveloping Hybrid Applications with IONIC
Developing Hybrid Applications with IONICFuat Buğra AYDIN
 
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015Alessio Delmonti
 
Selendroid - Selenium for Android
Selendroid - Selenium for AndroidSelendroid - Selenium for Android
Selendroid - Selenium for AndroidDominik Dary
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 
Ionic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without CompromisesIonic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without CompromisesJacob Friesen
 
Lesson 1. Create project Sunshine
Lesson 1. Create project SunshineLesson 1. Create project Sunshine
Lesson 1. Create project SunshineChanhyeong LEE
 
Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!Matheus Cardoso
 
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組み
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組みReact Nativeアプリをリリースし続けるために、最初に行う8つの取り組み
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組みYukiya Nakagawa
 
Hybrid Mobile Applications
Hybrid Mobile ApplicationsHybrid Mobile Applications
Hybrid Mobile ApplicationsRuwan Ranganath
 
jQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsjQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsBradley Holt
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentReto Meier
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)ejlp12
 
Cross-platform development frameworks
Cross-platform development frameworksCross-platform development frameworks
Cross-platform development frameworksCarlo Bernaschina
 
Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016Adrian Philipp
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium IntroNicholas Jansma
 
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
GR8Conf 2009. The Grails Plugin System by Graeme RocherGR8Conf 2009. The Grails Plugin System by Graeme Rocher
GR8Conf 2009. The Grails Plugin System by Graeme RocherGR8Conf
 

La actualidad más candente (20)

Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
 
Developing Hybrid Applications with IONIC
Developing Hybrid Applications with IONICDeveloping Hybrid Applications with IONIC
Developing Hybrid Applications with IONIC
 
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
 
Selendroid - Selenium for Android
Selendroid - Selenium for AndroidSelendroid - Selenium for Android
Selendroid - Selenium for Android
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Ionic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without CompromisesIonic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without Compromises
 
Lesson 1. Create project Sunshine
Lesson 1. Create project SunshineLesson 1. Create project Sunshine
Lesson 1. Create project Sunshine
 
Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!
 
Hybrid app development with ionic
Hybrid app development with ionicHybrid app development with ionic
Hybrid app development with ionic
 
[Lighting Talk] - Ionic 2 Tour
[Lighting Talk] - Ionic 2 Tour[Lighting Talk] - Ionic 2 Tour
[Lighting Talk] - Ionic 2 Tour
 
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組み
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組みReact Nativeアプリをリリースし続けるために、最初に行う8つの取り組み
React Nativeアプリをリリースし続けるために、最初に行う8つの取り組み
 
Hybrid Mobile Applications
Hybrid Mobile ApplicationsHybrid Mobile Applications
Hybrid Mobile Applications
 
jQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsjQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchApps
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android Development
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
 
Cross-platform development frameworks
Cross-platform development frameworksCross-platform development frameworks
Cross-platform development frameworks
 
Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
 
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
GR8Conf 2009. The Grails Plugin System by Graeme RocherGR8Conf 2009. The Grails Plugin System by Graeme Rocher
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
 

Similar a Native Android Development with Spring

Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Gustavo Fuentes Zurita
 
Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Gustavo Fuentes Zurita
 
From Containerization to Modularity
From Containerization to ModularityFrom Containerization to Modularity
From Containerization to Modularityoasisfeng
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Javaamaankhan
 
Android application development
Android application developmentAndroid application development
Android application developmentslidesuren
 
Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_authlzongren
 
Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009sullis
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Android development orientation for starters v4 seminar
Android development orientation for starters v4   seminarAndroid development orientation for starters v4   seminar
Android development orientation for starters v4 seminarJoemarie Amparo
 
Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for androidAdrian Mikeliunas
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump StartHaim Michael
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android ApplicationNandini Prabhu
 

Similar a Native Android Development with Spring (20)

Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9
 
Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9
 
From Containerization to Modularity
From Containerization to ModularityFrom Containerization to Modularity
From Containerization to Modularity
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Android - Anroid Pproject
Android - Anroid PprojectAndroid - Anroid Pproject
Android - Anroid Pproject
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_auth
 
Android
AndroidAndroid
Android
 
Mobile web development
Mobile web developmentMobile web development
Mobile web development
 
Oracle mcs overview 1029
Oracle mcs overview 1029Oracle mcs overview 1029
Oracle mcs overview 1029
 
Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Synapseindia android apps application
Synapseindia android apps applicationSynapseindia android apps application
Synapseindia android apps application
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android development orientation for starters v4 seminar
Android development orientation for starters v4   seminarAndroid development orientation for starters v4   seminar
Android development orientation for starters v4 seminar
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
 
Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for android
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump Start
 
iOS App Using cordova
iOS App Using cordovaiOS App Using cordova
iOS App Using cordova
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
 

Último

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Último (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Native Android Development with Spring

  • 1. Native Android Development with Spring Roy Clarkson Spring Mobile Projects Lead SpringSource, a division of VMware @royclarkson @springandroid © 2010 SpringSource, A division of VMware. All rights reserved 2012
  • 2. Introduction § What are the purposes of the Spring for Android and Spring Mobile projects? • Spring for Android provides support for building native Android applications utilizing Spring technologies, where applicable. • In contrast, Spring Mobile provides support for building mobile web applications. CONFIDENTIAL 2
  • 3. Spring for Android • Android Overview • Define the Problem • Review of REST • Basic Rest Template Example • Rest Template Overview • Maven Can Help • Showcase and Demos • Questions CONFIDENTIAL 3
  • 4. Android Adoption § Year-on-year growth rate of more than 250% § 850,000 new Android devices are activated each day § Over 300 million devices around the world § Over 450,000 apps available in Google Play § Over 1 billion app downloads per month http://googlemobile.blogspot.com/2012/02/androidmobile-world-congress-its-all.html CONFIDENTIAL 4
  • 5. Android Fragmentation § Current Distribution • Gingerbread 62% • Froyo 25.3% • Eclair 6.6% • Honeycomb 3.3% • Ice Cream Sandwich 1.6% http://developer.android.com/resources/dashboard/platform-versions.html CONFIDENTIAL 5
  • 6. Android is Familiar Applications are written in Java! (well, sort of) CONFIDENTIAL 6
  • 7. But not that Familiar... § Class Files • Android apps are compiled to class files. § DEX Format • Classes are compiled into the Dalvik Executable (DEX) format. • DEX format is required to run on the Dalvik Virtual Machine. § Dalvik VM • Not a true Java VM, because it does not operate on Java byte code. • Based on a subset of the Apache Harmony project. • Many of the classes from Java SE are available, but not all. CONFIDENTIAL 7
  • 8. Isolation of an App § Unique Linux User ID • Android OS assigns each app a unique Linux user ID. § Process Isolation • Within the VM, each app runs in its own Linux process. § Managed Lifecycle • The system manages the starting and stopping. CONFIDENTIAL 8
  • 9. Components of an Android App § Activities - An activity represents a single screen with a user interface. § Services - A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. § Content Providers - A content provider manages a shared set of application data. § Broadcast Receivers - A broadcast receiver is a component that responds to system-wide broadcast announcements. http://developer.android.com/guide/topics/fundamentals.html CONFIDENTIAL 9
  • 10. Android Manifest § contains the permissions requested by the app § Lists all of the components of an app <uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".HelloAndroidActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> CONFIDENTIAL 10
  • 11. A simple Activity package org.springsource; import android.app.Activity; import android.os.Bundle; public class HelloAndroidActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } CONFIDENTIAL 11
  • 12. STS and the ADT Plugin for Eclipse HelloAndroid Demo http://www.springsource.org/springsource-tool-suite-download http://developer.android.com/sdk/eclipse-adt.html CONFIDENTIAL 12
  • 13. How can Maven help? § Android4Maven • This project compiles android.jar from source and pulls out source and resource files to replicate android.jar in the SDK • http://sourceforge.net/projects/android4maven/ § Maven Android SDK Deployer • If you need to use Google maps, then you have to go this route • https://github.com/mosabua/maven-android-sdk-deployer § Android Maven Plugin • Provides support for Maven dependency management within Android projects • http://code.google.com/p/maven-android-plugin/ CONFIDENTIAL 13
  • 14. Android Maven Plugin Configuration <packaging>apk</packaging> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.1.1</version> <configuration> <sdk> <platform>${android-platform}</platform> </sdk> <deleteConflictingFiles>true</deleteConflictingFiles> <undeployBeforeDeploy>true</undeployBeforeDeploy> </configuration> <extensions>true</extensions> </plugin> https://repository.sonatype.org/index.html#nexus-search;quick~com.google.android CONFIDENTIAL 14
  • 15. Maven Commands Build your Android App $ mvn clean install Start the Emulator $ mvn android:emulator-start Deploy the app to the emulator $ mvn android:deploy Run the app $ mvn android:run http://maven-android-plugin-m2site.googlecode.com/svn/plugin-info.html CONFIDENTIAL 15
  • 16. Maven Demo CONFIDENTIAL 16
  • 17. m2eclipse Support § Android Configurator for M2E Maven Integration for Eclipse • An Eclipse plugin that adds support for integrating m2eclipse, Android Developer Tools, and the Android Maven Plugin • http://rgladwell.github.com/m2e-android/ § Maven Android archetypes • This project provides several Maven archetypes for Android. These archetypes allow you to quickly bootstrap a Maven project to develop an android application. • https://github.com/akquinet/android-archetypes CONFIDENTIAL 17
  • 18. This sounds too good! @rgladwell CONFIDENTIAL 18
  • 19. Spring for Android CONFIDENTIAL 19
  • 20. What problem are we trying to solve? § Concerns • REST has become a popular choice for architecting both public and private web services • The Android runtime provides HTTP clients capable of making HTTP connections and requests, but it does not have a fully featured REST client § Spring for Android Solution • The goal of Spring for Android Rest Template is to provide an easy to use, and functional REST client that supports marshaling objects from XML and JSON. CONFIDENTIAL 20
  • 21. REST § Origin • The term Representational State Transfer was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. § His paper suggests these four design principles: • Use HTTP methods explicitly. • POST, GET, PUT, DELETE • CRUD operations can be mapped to these existing methods • Be stateless. • State dependencies limit or restrict scalability • Expose directory structure-like URIs. • URI’s should be easily understood • Transfer XML, JavaScript Object Notation (JSON), or both. • Use XML or JSON to represent data objects or attributes CONFIDENTIAL 21
  • 22. Basic Rest Template Example § Google search example RestTemplate restTemplate = new RestTemplate(); String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={query}"; String result = restTemplate.getForObject(url, String.class, "SpringSource"); § Multiple parameters example RestTemplate restTemplate = new RestTemplate(); String url = "http://example.com/hotels/{hotel}/bookings/{booking}"; String result = restTemplate.getForObject(url, String.class, "42", “21”); CONFIDENTIAL 22
  • 23. Google Search Demo CONFIDENTIAL 23
  • 24. Spring for Android Rest Template § Based on SpringFramework • Originated as a fork of RestTemplate from SpringFramework. • Modifications were made to support Android. § RestTemplate class is the heart of the library • Entry points for the six main HTTP methods • DELETE - delete(...) • GET - getForObject(...) • HEAD - headForHeaders(...) • OPTIONS - optionsForAllow(...) • POST - postForLocation(...) • PUT - put(...) • any HTTP operation - exchange(...) and execute(...) CONFIDENTIAL 24
  • 25. HTTP Clients § SimpleClientHttpRequestFactory • Delegates to the standard J2SE facilities § HttpComponentsClientHttpRequestFactory • Delegates to the native HttpComponents HttpClient § CommonsClientHttpRequestFactory (deprecated) • Delegates to the Commons HttpClient which is not native to Android CONFIDENTIAL 25
  • 26. Message Converters § MappingJacksonHttpMessageConverter • object to JSON marshaling supported via the Jackson JSON Processor § SimpleXmlHttpMessageConverter • object to XML marshaling supported via the Simple XML Serializer § SyndFeedHttpMessageConverter • RSS and Atom feeds supported via the Android ROME Feed Reader CONFIDENTIAL 26
  • 27. Spring for Android Showcase § Examples • HTTP GET • JSON • XML • HTTP GET with Parameters • JSON • XML • HTTP POST • String • JSON • XML • MultiValueMap • RSS • ATOM CONFIDENTIAL 27
  • 28. Rest Template Demos CONFIDENTIAL 28
  • 29. Spring Social on Android § What is Spring Social? • Spring Social is an extension of the Spring Framework that allows you to connect your applications with Software-as-a-Service (SaaS) providers such as Facebook and Twitter. § How does it relate to Spring for Android? • Utilizes RestTemplate to make RESTful requests to providers. § How can Spring for Android help? • Auth library in Spring for Android provides a SQLiteConnectionRepository for use with Spring Social. CONFIDENTIAL 29
  • 30. Additional Resources § Slides: • http://portal.sliderocket.com/vmware/Native-Android-Development-with-Spring § Project Home: • http://www.springsource.org/spring-android § Sample Code: • https://github.com/SpringSource/spring-android-samples § Webinar: • http://www.springsource.org/node/3505 § Blog Posts: • http://blog.springsource.com/author/rclarkson/ CONFIDENTIAL 30