SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
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/

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Kürzlich hochgeladen (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

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/