SlideShare una empresa de Scribd logo
1 de 49
Descargar para leer sin conexión
Cross-Platform Data Access
                             for iPhone and Android




    MobileTechCon 2011 March 28th - 30th, Munich
       (c) 2011 @peterfriese / @itemismobile
cell phone usage is ubiquitous
s t
               e c
              n e
             o p
            h s
           p a
          r y
         u r
        o ve
      se e ifes
     u ge
   e a ur l
 w an o
    m of
to
many services only make sense
 when connected to the web
People are !fferent
... so #ey have !fferent ta$es!
countless devices
diversity of platforms
Problems   Solutions
(Missing) Connectivity
Solution: Detect Connectivity
Detecting Connectivity

States we need to detect:
Device not connected to internet
Connection slow
Server(s) not reachable
Server online, but requested service not available
Detecting Connectivity

iPhone Reachability
hostReach = [[Reachability
reachabilityWithHostName:@"www.apple.com"] retain];
[hostReach startNotifier];
[self updateInterfaceWithReachability: hostReach];
!
internetReach = [[Reachability
reachabilityForInternetConnection] retain];
[internetReach startNotifier];
[self updateInterfaceWithReachability: internetReach];

wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
[wifiReach startNotifier];
[self updateInterfaceWithReachability: wifiReach];


http://developer.apple.com/library/ios/#samplecode/Reachability/
Detecting Connectivity

Android ConnectivityManager
ConnectivityManager connectivity =
  (ConnectivityManager) getSystemService
    (Context.CONNECTIVITY_SERVICE);
NetworkInfo wifiInfo =
  connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo mobileInfo =
  connectivity.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);




http://developer.android.com/reference/android/net/ConnectivityManager.html
Different Data Formats



            Proprietary
           XML
              SOAP
             JSON
Solution: Use Different Parsers
A Fine Selection of Parsers
XML
SAXParser - (Android SDK)
DocumentBuilder - (Android SDK)
XmlPullParser - (Android SDK)

JSON
JSONTokener - (Android SDK)
JSON Simple - http://code.google.com/p/json-simple/
Jackson - http://jackson.codehaus.org/
GSon - http://code.google.com/p/google-gson/
Parsing JSON
Gson
public T transform(InputStream inputStream) {
	 InputStreamReader reader = new InputStreamReader(inputStream);
	 BufferedReader buffered = new BufferedReader(reader);
	 Gson gson = new Gson();
	 Type clazz = getGenericType();
	 T results = gson.fromJson(buffered, clazz);
	 try {
	 	 buffered.close();
	 	 reader.close();
	 	 inputStream.close();
	 } catch (IOException e) {
	 	 e.printStackTrace();
	 }
	 return results;
}

private Type getGenericType() {
	 Type type = ((ParameterizedType)getClass()
                     .getGenericSuperclass()).getActualTypeArguments()[0];
	 return type;
}
A Fine Selection of Parsers
XML
NSXMLParser - (iPhone SDK)
libxml2 - (iPhone SDK)
TouchXML - https://github.com/TouchCode/TouchXML
GDataXML - http://code.google.com/p/gdata-objectivec-
client/

JSON
TouchJSON - https://github.com/TouchCode/TouchJSON
json-framework - http://stig.github.com/json-framework/
YAJL - https://github.com/lloyd/yajl
JSONKit - https://github.com/johnezang/JSONKit
Parsing JSON
JSONKit

#import "JSONKit.h"

/...

- (id)transform:(NSString *)sourceString {
! id input = [sourceString objectFromJSONString];
    id result = nil;
    if ([input isKindOfClass:[NSArray class]]) {
        result = [self transformArray:input];
    }
    else if ([input isKindOfClass:[NSDictionary class]]) {
        result = [self transformDictionary:input];
    }

    return result;
}
Data Quality
Solution: Massage Data
Massaging                !!
In-App vs. Online
In-App massaging:
- needs to be rewritten for each platform
- ad-hoc enhancements virtually impossible (iPhone)

Server-side massaging:
- write once, re-use with every app
- problem with authentication (man-in-the-middle)
Massaging
Online tools
FeedSanitizer - http://feedsanitizer.appspot.com/
HTML Tidy - http://infohound.net/tidy/
JSONFormatter - http://jsonformatter.curiousconcept.com/

Roll your own
YQL - http://developer.yahoo.com/yql/
Node.js - http://nodejs.org/
Google App Engine - http://code.google.com/appengine/
Massaging with
var sponsorImageExpr = /Sponsored by:.*<img.*src="(.*)">?/;
var sponsoredByFilter = new SimpleFilter(function(data) {
! session = data;

!   if   (session.title.match(sponsorImageExpr)) {
!   !    sponsorlogoURL = session.title.match(sponsorImageExpr);
!   !    session.sponsorLogoURL = sponsorlogoURL[1];
!   !    session.title = session.title.replace(
                                            sponsorImageExpr, '');!!
! }
! return session;
});

var stripHTMLFilter = new SimpleFilter(function(string) {
! return string.replace(/</?[^>]+(>|$)/g, '');
});

var sessionsFilterChain =
! new FilterChain()
! ! .append(sponsoredByFilter)
! ! .append(stripHTMLFilter);
Massaging with

app.get('/sessions.:format', function(request, response) {
! var isXML = (request.params.format == 'xml');
! dataProvider.getAllSessions(function(sessions) {
! ! if (isXML) {
! ! ! response.header("Content-Type", "text/xml");
! ! ! response.render('sessions.ejs',
            { layout: false,
              locals: { sessions: sessions }
            });
! ! }
! ! else {
! ! ! response.header("Content-Type", "application/json");
! ! ! response.send(JSON.decycle(shallow(sessions, 3)));
! ! }! !
! });
});
Offline Data Access
Solution: Use Caching
Caching
Store in a local SQL database
SQLite - (Android SDK)
OrmLite - http://ormlite.com/
db4o - http://db4o.com/
ActiveAndroid - https://www.activeandroid.com/
AndroidActiveRecord -
 http://code.google.com/p/android-active-record/

Store in the local file system
Use cache directory - Context.getCacheDir()
Caching
Store in a local SQL database
SQLite - (iPhone SDK)
ActiveRecord - https://github.com/aptiva/activerecord
CoreData - (iPhone SDK)

Store in the local file system
URLCache sample - http://developer.apple.com/
library/ios/#samplecode/URLCache
Putting it all together
Solution: Data Access Frameworks
Features

Handle spotty connectivity
Support multiple data formats (XML / JSON)
Massage data
Provide offline data access
Map data to language concepts
Data Access
Frameworks
ActiveAndroid - https://www.activeandroid.com/

AndroidActiveRecord -
 http://code.google.com/p/android-active-record/

RESTProvider -
 https://github.com/novoda/RESTProvider
Data Access
Frameworks / Features




                                                            Flex. Mapping
                      Connectivity




                                                  Caching
                                     JSON

                                            XML
ActiveAndroid           !            !      !     "          "
AndroidActiveRecord     !            !      !     "          "
RESTProvider           #             "      "     #* "

                                                     * experimental
Data Access
Frameworks / Features




                                                            Flex. Mapping
                      Connectivity




                                                  Caching
                                     JSON

                                            XML
                                                              ce
                                                       sis ten
ActiveAndroid           !            !      !     "  er
                                                    P" Ws
                                                        F
AndroidActiveRecord     !            !      !     "          "
RESTProvider           #             "      "     #* "

                                                     * experimental
Data Access
    RESTProvider
public class TwitterFeedExample extends ListActivity {
   @Override public void onCreate(Bundle b) {
   	 super.onCreate(b);
	 	 CPAsyncHandler g = new CPAsyncHandler(getContentResolver());
	 	 g.startQuery(1, null, Uri.parse("content://novoda.rest.test.twitter"),
   	 	 null, "q=?", new String[] { "droidcon" }, null);
	 }

	   private class CPAsyncHandler extends AsyncQueryHandler {
	   	 @Override
	   	 protected void onQueryComplete(int token, Object cookie, Cursor c) {
	   	 	 super.onQueryComplete(token, cookie, c);
	   	 	 setListAdapter(new SimpleCursorAdapter(TwitterFeedExample.this,
	   	 	 	 	 android.R.layout.simple_list_item_2, c, new String[] {
	   	 	 	 	 	 	 "from_user", "text" }, new int[] {
	   	 	 	 	 	 	 android.R.id.text1, android.R.id.text2 }));
	   	 }
	   }
}
Data Access
Frameworks
iPhone on Rails - http://iphoneonrails.com/
CoreResource - http://coreresource.org/
RestKit - http://restkit.org/
Data Access
Frameworks / Features




                                                         Flex. Mapping
                   Connectivity




                                               Caching
                                  JSON

                                         XML
iPhoneOnRails       #             "      "      !         "
CoreResource        "             "      "     "          "
RESTKit             "             "      "     "          "
Data Access
     RESTKit
- (void)loadContact {
  RKObjectManager* manager = [RKObjectManager
      objectManagerWithBaseURL:@"http://restkit.org"];

    [manager loadObjectsAtResourcePath:@"/contacts/1"
             objectClass:[Contact class]
             delegate:self]
}

// RKObjectLoaderDelegate methods

- (void)objectLoader:(RKObjectLoader*)objectLoader
  didLoadObjects:(NSArray*)objects
{
  Contact* contact = [objects objectAtIndex:0];
  NSLog(@"Loaded Contact ID #%@ -> Name: %@,
        Company: %@", contact.id, contact.name, contact.company);
}
Plethora of Languages
                           ?@#!

Objective-C
                    C#            Java




              JavaScript
Solution: Use A DSL
Solution: Use A DSL
                   Entities




                    Data                            View
                   Mappers                        Controllers




                    Entity
                 Descriptions

    DSL
                              iOS / Objective-C
describes data
  model and
mapping rules


                   Entities
  DSL IDE



                 Transformers                     Activities




                   Content
                  Providers


                                Android / Java
DSL Sample
   Fetching Blog Items

entity BlogItem {
	 String guid
	 String title
	 String link
	 String description
	 String creator
}

contentprovider Blogposts
	 returns BlogItem[]
	 fetches XML
	 	 from (FEEDSANITIZER_URL "/sanitize?url=http%3A%2F%2Fblogs.itemis.de%2F
%3Fshowfeed%3D1&format=rss")
	 	 selects "rss.channel.item"
http://mobile.itemis.de

@peterfriese | http://peterfriese.de
Image credits
  Tower bridge - http://www.flickr.com/photos/anirudhkoul/3499471010/
  Little girl with cell - http://www.flickr.com/photos/spitzgogo/286917522/
  Gray-haired guy on bench - http://www.flickr.com/photos/mr_t_in_dc/5524143121/
  Girl with hoody, texting - http://www.flickr.com/photos/lanier67/2979124681/
  Fast girl on bike - http://www.flickr.com/photos/pixel_addict/465394708/
  NY Apple Store - http://www.flickr.com/photos/smoovey/3749038495/
  Guy driving and texting - http://www.flickr.com/photos/lord-jim/4794895023/
  Portraits:
     http://www.flickr.com/photos/46914331@N03/4312184861/
     http://www.flickr.com/photos/pagedooley/4258558487/
     http://www.flickr.com/photos/yuri-samoilov/4105603525/
     http://www.flickr.com/photos/adriel_socrates/5560606768/
     http://www.flickr.com/photos/adriel_socrates/5560592742/in/photostream/
     http://www.flickr.com/photos/kkoshy/4729866481/
     http://www.flickr.com/photos/pagedooley/4258558741/
     http://www.flickr.com/photos/mescon/3668279183/
     http://www.flickr.com/photos/mescon/2984454695/
     http://www.flickr.com/photos/ter-burg/428205830/
     http://www.flickr.com/photos/eudaimos/2107219904/
  Mountains, Lake and Boat - http://www.flickr.com/photos/visulogik/2180603155/
  Dead Sea Scrolls - http://www.flickr.com/photos/kjfnjy/5249145754/
  Lines of communication - http://www.flickr.com/photos/ruudhein/4442182264/
  Satellite dish - http://www.flickr.com/photos/26652703@N02/2502519971/

Más contenido relacionado

La actualidad más candente

Denys Serhiienko "ASGI in depth"
Denys Serhiienko "ASGI in depth"Denys Serhiienko "ASGI in depth"
Denys Serhiienko "ASGI in depth"Fwdays
 
Enter the app era with ruby on rails
Enter the app era with ruby on railsEnter the app era with ruby on rails
Enter the app era with ruby on railsMatteo Collina
 
JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegapyangdj
 
Laravel dokumentacja Restful API - swagger
Laravel dokumentacja Restful API - swaggerLaravel dokumentacja Restful API - swagger
Laravel dokumentacja Restful API - swaggerLaravel Poland MeetUp
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in SwiftPeter Friese
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and PythonPiXeL16
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web developmentJohannes Brodwall
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedMarcinStachniuk
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWTArnaud Tournier
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...Codemotion
 
Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk   Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk OdessaJS Conf
 
Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Yasuko Ohba
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Jens Ravens
 

La actualidad más candente (19)

Denys Serhiienko "ASGI in depth"
Denys Serhiienko "ASGI in depth"Denys Serhiienko "ASGI in depth"
Denys Serhiienko "ASGI in depth"
 
Enter the app era with ruby on rails
Enter the app era with ruby on railsEnter the app era with ruby on rails
Enter the app era with ruby on rails
 
Getting Started-with-Laravel
Getting Started-with-LaravelGetting Started-with-Laravel
Getting Started-with-Laravel
 
JSON Injection
JSON InjectionJSON Injection
JSON Injection
 
JavaScript
JavaScriptJavaScript
JavaScript
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
Laravel dokumentacja Restful API - swagger
Laravel dokumentacja Restful API - swaggerLaravel dokumentacja Restful API - swagger
Laravel dokumentacja Restful API - swagger
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in Swift
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
Ams adapters
Ams adaptersAms adapters
Ams adapters
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learned
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk   Specification-Driven Development of REST APIs by Alexander Zinchuk
Specification-Driven Development of REST APIs by Alexander Zinchuk
 
Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017
 

Destacado

JPA1404 Context-based Access Control Systems for Mobile Devices
JPA1404  Context-based Access Control Systems for Mobile DevicesJPA1404  Context-based Access Control Systems for Mobile Devices
JPA1404 Context-based Access Control Systems for Mobile Deviceschennaijp
 
Context based access control systems for mobile devices
Context based access control systems for mobile devicesContext based access control systems for mobile devices
Context based access control systems for mobile devicesshanofa sanu
 
Context based access control systems for mobile devices
Context based access control systems for mobile devicesContext based access control systems for mobile devices
Context based access control systems for mobile devicesLeMeniz Infotech
 

Destacado (7)

JPA1404 Context-based Access Control Systems for Mobile Devices
JPA1404  Context-based Access Control Systems for Mobile DevicesJPA1404  Context-based Access Control Systems for Mobile Devices
JPA1404 Context-based Access Control Systems for Mobile Devices
 
Chapter11 new
Chapter11 newChapter11 new
Chapter11 new
 
Context based access control systems for mobile devices
Context based access control systems for mobile devicesContext based access control systems for mobile devices
Context based access control systems for mobile devices
 
Io (2)
Io (2)Io (2)
Io (2)
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
Tao zhang
Tao zhangTao zhang
Tao zhang
 
Context based access control systems for mobile devices
Context based access control systems for mobile devicesContext based access control systems for mobile devices
Context based access control systems for mobile devices
 

Similar a Cross-Platform Data Access for Android and iPhone

The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...SPTechCon
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better NetworkingITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better NetworkingIstanbul Tech Talks
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2Geoffrey Fox
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0Eugenio Romano
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)ejlp12
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Luc Bors
 
Approaches to mobile site development
Approaches to mobile site developmentApproaches to mobile site development
Approaches to mobile site developmentErik Mitchell
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global dominationStfalcon Meetups
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on MobileAdam Lu
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...Robert Nyman
 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom Joshua Long
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 

Similar a Cross-Platform Data Access for Android and iPhone (20)

NodeJS
NodeJSNodeJS
NodeJS
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better NetworkingITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)
 
Approaches to mobile site development
Approaches to mobile site developmentApproaches to mobile site development
Approaches to mobile site development
 
Always on! Or not?
Always on! Or not?Always on! Or not?
Always on! Or not?
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global domination
 
Frontend. Global domination.
Frontend. Global domination.Frontend. Global domination.
Frontend. Global domination.
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 

Más de Peter Friese

Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsPeter Friese
 
Firebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopFirebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopPeter Friese
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsPeter Friese
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesPeter Friese
 
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift LeedsPeter Friese
 
Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple DevelopersPeter Friese
 
Building Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebaseBuilding Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebasePeter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebasePeter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebasePeter Friese
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase AuthPeter Friese
 
Five Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthFive Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthPeter Friese
 
Building High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantBuilding High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantPeter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Peter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GooglePeter Friese
 
What's new in Android Wear 2.0
What's new in Android Wear 2.0What's new in Android Wear 2.0
What's new in Android Wear 2.0Peter Friese
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinPeter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services RockPeter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 
Google+ for Mobile Apps on iOS and Android
Google+ for Mobile Apps on iOS and AndroidGoogle+ for Mobile Apps on iOS and Android
Google+ for Mobile Apps on iOS and AndroidPeter Friese
 

Más de Peter Friese (20)

Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
 
Firebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopFirebase & SwiftUI Workshop
Firebase & SwiftUI Workshop
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroes
 
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 
Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple Developers
 
Building Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebaseBuilding Apps with SwiftUI and Firebase
Building Apps with SwiftUI and Firebase
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth
 
Five Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthFive Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase Auth
 
Building High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantBuilding High-Quality Apps for Google Assistant
Building High-Quality Apps for Google Assistant
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
 
What's new in Android Wear 2.0
What's new in Android Wear 2.0What's new in Android Wear 2.0
What's new in Android Wear 2.0
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & Xamarin
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services Rock
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
Google+ for Mobile Apps on iOS and Android
Google+ for Mobile Apps on iOS and AndroidGoogle+ for Mobile Apps on iOS and Android
Google+ for Mobile Apps on iOS and Android
 

Último

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Último (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Cross-Platform Data Access for Android and iPhone

  • 1. Cross-Platform Data Access for iPhone and Android MobileTechCon 2011 March 28th - 30th, Munich (c) 2011 @peterfriese / @itemismobile
  • 2. cell phone usage is ubiquitous
  • 3.
  • 4. s t e c n e o p h s p a r y u r o ve se e ifes u ge e a ur l w an o m of to
  • 5. many services only make sense when connected to the web
  • 7. ... so #ey have !fferent ta$es!
  • 10. Problems Solutions
  • 13. Detecting Connectivity States we need to detect: Device not connected to internet Connection slow Server(s) not reachable Server online, but requested service not available
  • 14. Detecting Connectivity iPhone Reachability hostReach = [[Reachability reachabilityWithHostName:@"www.apple.com"] retain]; [hostReach startNotifier]; [self updateInterfaceWithReachability: hostReach]; ! internetReach = [[Reachability reachabilityForInternetConnection] retain]; [internetReach startNotifier]; [self updateInterfaceWithReachability: internetReach]; wifiReach = [[Reachability reachabilityForLocalWiFi] retain]; [wifiReach startNotifier]; [self updateInterfaceWithReachability: wifiReach]; http://developer.apple.com/library/ios/#samplecode/Reachability/
  • 15. Detecting Connectivity Android ConnectivityManager ConnectivityManager connectivity = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobileInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); http://developer.android.com/reference/android/net/ConnectivityManager.html
  • 16. Different Data Formats Proprietary XML SOAP JSON
  • 18. A Fine Selection of Parsers XML SAXParser - (Android SDK) DocumentBuilder - (Android SDK) XmlPullParser - (Android SDK) JSON JSONTokener - (Android SDK) JSON Simple - http://code.google.com/p/json-simple/ Jackson - http://jackson.codehaus.org/ GSon - http://code.google.com/p/google-gson/
  • 19. Parsing JSON Gson public T transform(InputStream inputStream) { InputStreamReader reader = new InputStreamReader(inputStream); BufferedReader buffered = new BufferedReader(reader); Gson gson = new Gson(); Type clazz = getGenericType(); T results = gson.fromJson(buffered, clazz); try { buffered.close(); reader.close(); inputStream.close(); } catch (IOException e) { e.printStackTrace(); } return results; } private Type getGenericType() { Type type = ((ParameterizedType)getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; return type; }
  • 20. A Fine Selection of Parsers XML NSXMLParser - (iPhone SDK) libxml2 - (iPhone SDK) TouchXML - https://github.com/TouchCode/TouchXML GDataXML - http://code.google.com/p/gdata-objectivec- client/ JSON TouchJSON - https://github.com/TouchCode/TouchJSON json-framework - http://stig.github.com/json-framework/ YAJL - https://github.com/lloyd/yajl JSONKit - https://github.com/johnezang/JSONKit
  • 21. Parsing JSON JSONKit #import "JSONKit.h" /... - (id)transform:(NSString *)sourceString { ! id input = [sourceString objectFromJSONString]; id result = nil; if ([input isKindOfClass:[NSArray class]]) { result = [self transformArray:input]; } else if ([input isKindOfClass:[NSDictionary class]]) { result = [self transformDictionary:input]; } return result; }
  • 24. Massaging !! In-App vs. Online In-App massaging: - needs to be rewritten for each platform - ad-hoc enhancements virtually impossible (iPhone) Server-side massaging: - write once, re-use with every app - problem with authentication (man-in-the-middle)
  • 25. Massaging Online tools FeedSanitizer - http://feedsanitizer.appspot.com/ HTML Tidy - http://infohound.net/tidy/ JSONFormatter - http://jsonformatter.curiousconcept.com/ Roll your own YQL - http://developer.yahoo.com/yql/ Node.js - http://nodejs.org/ Google App Engine - http://code.google.com/appengine/
  • 26. Massaging with var sponsorImageExpr = /Sponsored by:.*<img.*src="(.*)">?/; var sponsoredByFilter = new SimpleFilter(function(data) { ! session = data; ! if (session.title.match(sponsorImageExpr)) { ! ! sponsorlogoURL = session.title.match(sponsorImageExpr); ! ! session.sponsorLogoURL = sponsorlogoURL[1]; ! ! session.title = session.title.replace( sponsorImageExpr, '');!! ! } ! return session; }); var stripHTMLFilter = new SimpleFilter(function(string) { ! return string.replace(/</?[^>]+(>|$)/g, ''); }); var sessionsFilterChain = ! new FilterChain() ! ! .append(sponsoredByFilter) ! ! .append(stripHTMLFilter);
  • 27. Massaging with app.get('/sessions.:format', function(request, response) { ! var isXML = (request.params.format == 'xml'); ! dataProvider.getAllSessions(function(sessions) { ! ! if (isXML) { ! ! ! response.header("Content-Type", "text/xml"); ! ! ! response.render('sessions.ejs', { layout: false, locals: { sessions: sessions } }); ! ! } ! ! else { ! ! ! response.header("Content-Type", "application/json"); ! ! ! response.send(JSON.decycle(shallow(sessions, 3))); ! ! }! ! ! }); });
  • 30. Caching Store in a local SQL database SQLite - (Android SDK) OrmLite - http://ormlite.com/ db4o - http://db4o.com/ ActiveAndroid - https://www.activeandroid.com/ AndroidActiveRecord - http://code.google.com/p/android-active-record/ Store in the local file system Use cache directory - Context.getCacheDir()
  • 31. Caching Store in a local SQL database SQLite - (iPhone SDK) ActiveRecord - https://github.com/aptiva/activerecord CoreData - (iPhone SDK) Store in the local file system URLCache sample - http://developer.apple.com/ library/ios/#samplecode/URLCache
  • 32. Putting it all together
  • 33. Solution: Data Access Frameworks
  • 34. Features Handle spotty connectivity Support multiple data formats (XML / JSON) Massage data Provide offline data access Map data to language concepts
  • 35. Data Access Frameworks ActiveAndroid - https://www.activeandroid.com/ AndroidActiveRecord - http://code.google.com/p/android-active-record/ RESTProvider - https://github.com/novoda/RESTProvider
  • 36. Data Access Frameworks / Features Flex. Mapping Connectivity Caching JSON XML ActiveAndroid ! ! ! " " AndroidActiveRecord ! ! ! " " RESTProvider # " " #* " * experimental
  • 37. Data Access Frameworks / Features Flex. Mapping Connectivity Caching JSON XML ce sis ten ActiveAndroid ! ! ! " er P" Ws F AndroidActiveRecord ! ! ! " " RESTProvider # " " #* " * experimental
  • 38. Data Access RESTProvider public class TwitterFeedExample extends ListActivity { @Override public void onCreate(Bundle b) { super.onCreate(b); CPAsyncHandler g = new CPAsyncHandler(getContentResolver()); g.startQuery(1, null, Uri.parse("content://novoda.rest.test.twitter"), null, "q=?", new String[] { "droidcon" }, null); } private class CPAsyncHandler extends AsyncQueryHandler { @Override protected void onQueryComplete(int token, Object cookie, Cursor c) { super.onQueryComplete(token, cookie, c); setListAdapter(new SimpleCursorAdapter(TwitterFeedExample.this, android.R.layout.simple_list_item_2, c, new String[] { "from_user", "text" }, new int[] { android.R.id.text1, android.R.id.text2 })); } } }
  • 39. Data Access Frameworks iPhone on Rails - http://iphoneonrails.com/ CoreResource - http://coreresource.org/ RestKit - http://restkit.org/
  • 40. Data Access Frameworks / Features Flex. Mapping Connectivity Caching JSON XML iPhoneOnRails # " " ! " CoreResource " " " " " RESTKit " " " " "
  • 41. Data Access RESTKit - (void)loadContact { RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://restkit.org"]; [manager loadObjectsAtResourcePath:@"/contacts/1" objectClass:[Contact class] delegate:self] } // RKObjectLoaderDelegate methods - (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects { Contact* contact = [objects objectAtIndex:0]; NSLog(@"Loaded Contact ID #%@ -> Name: %@, Company: %@", contact.id, contact.name, contact.company); }
  • 42. Plethora of Languages ?@#! Objective-C C# Java JavaScript
  • 44. Solution: Use A DSL Entities Data View Mappers Controllers Entity Descriptions DSL iOS / Objective-C describes data model and mapping rules Entities DSL IDE Transformers Activities Content Providers Android / Java
  • 45. DSL Sample Fetching Blog Items entity BlogItem { String guid String title String link String description String creator } contentprovider Blogposts returns BlogItem[] fetches XML from (FEEDSANITIZER_URL "/sanitize?url=http%3A%2F%2Fblogs.itemis.de%2F %3Fshowfeed%3D1&format=rss") selects "rss.channel.item"
  • 46.
  • 47.
  • 49. Image credits Tower bridge - http://www.flickr.com/photos/anirudhkoul/3499471010/ Little girl with cell - http://www.flickr.com/photos/spitzgogo/286917522/ Gray-haired guy on bench - http://www.flickr.com/photos/mr_t_in_dc/5524143121/ Girl with hoody, texting - http://www.flickr.com/photos/lanier67/2979124681/ Fast girl on bike - http://www.flickr.com/photos/pixel_addict/465394708/ NY Apple Store - http://www.flickr.com/photos/smoovey/3749038495/ Guy driving and texting - http://www.flickr.com/photos/lord-jim/4794895023/ Portraits: http://www.flickr.com/photos/46914331@N03/4312184861/ http://www.flickr.com/photos/pagedooley/4258558487/ http://www.flickr.com/photos/yuri-samoilov/4105603525/ http://www.flickr.com/photos/adriel_socrates/5560606768/ http://www.flickr.com/photos/adriel_socrates/5560592742/in/photostream/ http://www.flickr.com/photos/kkoshy/4729866481/ http://www.flickr.com/photos/pagedooley/4258558741/ http://www.flickr.com/photos/mescon/3668279183/ http://www.flickr.com/photos/mescon/2984454695/ http://www.flickr.com/photos/ter-burg/428205830/ http://www.flickr.com/photos/eudaimos/2107219904/ Mountains, Lake and Boat - http://www.flickr.com/photos/visulogik/2180603155/ Dead Sea Scrolls - http://www.flickr.com/photos/kjfnjy/5249145754/ Lines of communication - http://www.flickr.com/photos/ruudhein/4442182264/ Satellite dish - http://www.flickr.com/photos/26652703@N02/2502519971/