Your SlideShare is downloading. ×
  • Like
Connecting to Web Services on Android June 2 2010
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Connecting to Web Services on Android June 2 2010

  • 9,560 views
Published

Open Source Bridge 2010 …

Open Source Bridge 2010
June 2, 2010
Portland Oregon

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
9,560
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
391
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Connecting to Web Services on Android Sean Sullivan June 2, 2010
  • 2. HTTP request HTTP response
  • 3. • HTTP • XML • JSON • OAuth
  • 4. + HTTP Option 1 • java.net.URL • java.net.HttpURLConnection Option 2 • HttpClient 4.0 API
  • 5. HttpClient 4.0 API • org.apache.http.client.HttpClient • org.apache.http.impl.client.DefaultHttpClient
  • 6. 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
  • 7. HttpClient 4.0 API • org.apache.http.HttpResponse • org.apache.http.StatusLine • org.apache.http.HttpEntity • org.apache.http.utils.EntityUtils
  • 8. HttpClient programming • HTTP response status code • I/O exceptions • timeouts • gzip
  • 9. HttpClient programming synchronous invocation public HttpResponse execute(HttpUriRequest request) asynchronous invocation public HttpResponse execute(HttpUriRequest request, ResponseHandler handler)
  • 10. UI programming • user clicks on button • onClick listener • Don’t block the UI thread! • Tip: use java.lang.Runnable
  • 11. Response formats • XML • JSON • RSS, Atom • other
  • 12. JSON processing • json.org package • Google GSON library • XStream + Jettison * • json-lib * * does not work on Android 1.x
  • 13. XML processing • org.w3c.dom package (DOM) • org.xml.sax package (SAX) • org.xmlpull package (XPP) • XStream • JDOM • Apache XmlBeans* * does not work on Android 1.x
  • 14. RSS and Atom • Rome library * • Apache Abdera library * * does not work on Android 1.x
  • 15. Client libraries code.google.com/p/jfireeagle code.google.com/p/jpoco code.google.com/p/meetup-java-client
  • 16. Client libraries code.google.com/p/gdata-java-client code.google.com/p/upcoming-java-client flickrj.sourceforge.net
  • 17. Conclusion • HttpClient API • use XStream for XML processing • use Google GSON for JSON processing • OAuth has a learning curve
  • 18. Thank you