Connecting to Web Services on Android
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Connecting to Web Services on Android

on

  • 148,405 views

Connecting to Web Services on Android

Connecting to Web Services on Android
Android Dev Camp Amsterdam
January 2009

Statistics

Views

Total Views
148,405
Views on SlideShare
147,144
Embed Views
1,261

Actions

Likes
49
Downloads
3,221
Comments
13

35 Embeds 1,261

http://www.slideshare.net 907
http://eclipseplugincentral.blogspot.com 74
http://jtechnicals.blogspot.com 61
http://eclipseplugincentral.blogspot.in 44
http://sdandbi.blogspot.it 34
http://www.androidchina.org.cn 27
http://youmobileapp.blogspot.com 24
http://sdandbi.blogspot.com 19
http://www.linux.rk.edu.pl 13
http://wegotguru.com 8
http://youmobileapp.blogspot.it 6
http://telcoloewe.wordpress.com 6
http://eclipseplugincentral.blogspot.ru 5
http://jtechnicals.blogspot.ru 3
http://eclipseplugincentral.blogspot.de 2
http://eclipseplugincentral.blogspot.nl 2
http://127.0.0.1 2
http://www.scoop.it 2
http://ibloglearning.blogspot.com 2
http://jtechnicals.blogspot.in 2
http://www.eclipseplugincentral.blogspot.com 2
http://translate.googleusercontent.com 2
http://www.verious.com 2
http://www.sdandbi.blogspot.it 1
http://eclipseplugincentral.blogspot.pt 1
https://www.linkedin.com 1
http://jtechnicals.blogspot.com.es 1
http://eclipseplugincentral.blogspot.ca 1
http://eclipseplugincentral.blogspot.tw 1
http://jtechnicals.blogspot.nl 1
http://eclipseplugincentral.blogspot.co.uk 1
http://www.eclipseplugincentral.blogspot.sg 1
http://youmobileapp.blogspot.co.uk 1
http://javieratorre.blogspot.com 1
http://pmomale-ld1 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

15 of 13 Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • thank you vary much ,this knowledge is very useful :-* ...
    Are you sure you want to
    Your message goes here
    Processing…
  • mantapp
    Are you sure you want to
    Your message goes here
    Processing…
  • gud
    Are you sure you want to
    Your message goes here
    Processing…
  • Thank you
    Are you sure you want to
    Your message goes here
    Processing…
  • Very Very Thanks.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Connecting to Web Services on Android Presentation Transcript

  • 1. Connecting to Web Services Sean Sullivan Android Dev Camp Amsterdam 8 January 2009
  • 2. +
  • 3. • HTTP • XML • JSON • OAuth
  • 4. HTTP request XML response
  • 5. http://code.google.com/p/jfireeagle
  • 6. jfireeagle uses: • HttpClient API • XStream • OAuth Java library
  • 7. “An open protocol to allow secure API authorization in a simple and standard method from desktop and web applications”
  • 8. • use OAuth to access protected data • your application needs to obtain an access token from the service provider • service provider will issue access token after the user grants permission
  • 9. + http://code.google.com/p/oauth
  • 10. + jfireeagle http://code.google.com/p/jfireeagle/wiki/Android jpoco http://code.google.com/p/jpoco/wiki/Android
  • 11. + HTTP Option 1 • java.net.URL • java.net.HttpURLConnection Option 2 • HttpClient 4.0 API
  • 12. HttpClient 4.0 API • org.apache.http.client.HttpClient • org.apache.http.impl.client.DefaultHttpClient
  • 13. HttpClient 4.0 API • org.apache.http.client.methods.HttpGet • org.apache.http.client.methods.HttpPost • org.apache.http.client.methods.HttpPut • org.apache.http.client.methods.HttpDelete
  • 14. HttpClient 4.0 API • org.apache.http.HttpResponse • org.apache.http.StatusLine • org.apache.http.HttpEntity • org.apache.http.utils.EntityUtils
  • 15. HttpClient programming • HTTP response status code • I/O exceptions • timeouts • gzip?
  • 16. HttpClient programming synchronous invocation public HttpResponse execute(HttpUriRequest request) asynchronous invocation public HttpResponse execute(HttpUriRequest request, ResponseHandler handler)
  • 17. Android UI thread • user clicks on button • onClick listener • Don’t block the UI thread! • Tip: use java.lang.Runnable
  • 18. Response formats • XML • JSON • RSS, Atom • other
  • 19. XML processing • org.w3c.dom package (DOM) • org.xml.sax package (SAX) • org.xmlpull package (XPP3) • XStream • JDOM • Apache XmlBeans * * does not work on Android 1.0
  • 20. JSON processing • org.json package • Google GSON library * • XStream + Jettison * • json-lib * * does not work on Android 1.0
  • 21. Client libraries • code.google.com/p/jfireeagle • code.google.com/p/jpoco • code.google.com/p/meetup-java-client • code.google.com/p/upcoming-java-client • code.google.com/p/gdata-java-client • flickrj.sourceforge.net
  • 22. Conclusion • HttpClient API • use XStream for XML processing • use org.json package for JSON processing • OAuth has a learning curve • OAuth affects user experience
  • 23. Thank you
  • 24. Resources • http://code.google.com/android/documentation.html • http://hc.apache.org/httpcomponents-client • http://code.google.com/p/oauth • http://xstream.codehaus.org