Beruflich Dokumente
Kultur Dokumente
Sean Sullivan
Android Dev Camp Amsterdam
8 January 2009
+
• HTTP
• XML
• JSON
• OAuth
HTTP request
XML response
http://code.google.com/p/jfireeagle
jfireeagle uses:
• HttpClient API
• XStream
• OAuth Java library
“An open protocol to allow secure API
authorization in a simple and standard method
from desktop and web applications”
• 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
+
http://code.google.com/p/oauth
+
jfireeagle
http://code.google.com/p/jfireeagle/wiki/Android
jpoco
http://code.google.com/p/jpoco/wiki/Android
+ HTTP
Option 1
• java.net.URL
• java.net.HttpURLConnection
Option 2
• HttpClient 4.0 API
HttpClient 4.0 API
• org.apache.http.client.HttpClient
• org.apache.http.impl.client.DefaultHttpClient
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
HttpClient 4.0 API
• org.apache.http.HttpResponse
• org.apache.http.StatusLine
• org.apache.http.HttpEntity
• org.apache.http.utils.EntityUtils
HttpClient programming
synchronous invocation
public HttpResponse execute(HttpUriRequest request)
asynchronous invocation
public HttpResponse execute(HttpUriRequest request,
ResponseHandler handler)
Android UI thread
• XML
• JSON
• RSS, Atom
• other
XML processing
• org.w3c.dom package (DOM)
• org.xml.sax package (SAX)
• org.xmlpull package (XPP3)
• XStream
• JDOM
• Apache XmlBeans *
• XStream + Jettison
*
• json-lib
*
• HttpClient API
• use XStream for XML processing
• use org.json package for JSON processing
• OAuth has a learning curve
• OAuth affects user experience
Thank you
Resources
• http://code.google.com/android/documentation.html
• http://hc.apache.org/httpcomponents-client
• http://code.google.com/p/oauth
• http://xstream.codehaus.org