Figure 6.4 The Delicious recent posts screen from the NetworkExplorer application in Java

Generating QR Code in Java Figure 6.4 The Delicious recent posts screen from the NetworkExplorer application

Listing 6.10
QR Code ISO/IEC18004 Creation In Java
Using Barcode creation for Android Control to generate, create Denso QR Bar Code image in Android applications.
www.OnBarcode.com
Creating QR Code ISO/IEC18004 In Java
Using Barcode generator for Android Control to generate, create QR Code JIS X 0510 image in Android applications.
www.OnBarcode.com
Figure 6.4 The Delicious recent posts screen from the NetworkExplorer application
Encode Code 128 Code Set A In Java
Using Barcode drawer for Android Control to generate, create ANSI/AIM Code 128 image in Android applications.
www.OnBarcode.com
Painting Barcode In Java
Using Barcode creation for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
The Delicious HTTPS POX API with authentication from an Activity
PDF-417 2d Barcode Drawer In Java
Using Barcode drawer for Android Control to generate, create PDF-417 2d barcode image in Android applications.
www.OnBarcode.com
Encode ECC200 In Java
Using Barcode drawer for Android Control to generate, create Data Matrix 2d barcode image in Android applications.
www.OnBarcode.com
public class DeliciousRecentPosts extends Activity { private static final String CLASSTAG = DeliciousRecentPosts.class.getSimpleName(); private static final String URL_GET_POSTS_RECENT = "https://api.del.icio.us/v1/posts/recent "; . . . member var declarations for user, pass, output, and button (Views) omitted for brevity, private final Handler handler = new Handler() { public void handleMessage(final Message msg) { progressDialog.dismiss();
Making EAN13 In Java
Using Barcode printer for Android Control to generate, create EAN13 image in Android applications.
www.OnBarcode.com
Postnet Creation In Java
Using Barcode encoder for Android Control to generate, create Delivery Point Barcode (DPBC) image in Android applications.
www.OnBarcode.com
Include Delicious URL
create qr code in excel
Using Barcode generation for Office Excel Control to generate, create QR-Code image in Excel applications. barcode generator excel 2010 create qr code in excel
www.OnBarcode.com
Quick Response Code Creator In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
www.OnBarcode.com
Provide Handler to update UI
Barcode Scanner In C#
Using Barcode Control SDK for VS .NET Control to generate, create, read, scan barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Generating QR In .NET Framework
Using Barcode generator for Reporting Service Control to generate, create QR Code 2d barcode image in Reporting Service applications.
www.OnBarcode.com
Networking and web services
Generating Code-128 In .NET Framework
Using Barcode printer for Reporting Service Control to generate, create Code 128 image in Reporting Service applications.
www.OnBarcode.com
Draw UPC Code In None
Using Barcode creation for Software Control to generate, create GS1 - 12 image in Software applications.
www.OnBarcode.com
String bundleResult = msg.getData().getString("RESPONSE"); output.setText(parseXMLResult(bundleResult)); } }; @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); this.setContentView(R.layout.delicious_posts); . . . inflate views omitted for brevity this.button.setOnClickListener(new OnClickListener() { public void onClick(final View v) { output.setText(""); performRequest(user.getText().toString(), pass.getText().toString()); Pass credentials to } performRequest }); }; . . . onPause omitted for brevity private void performRequest(String user, String pass) { this.progressDialog = ProgressDialog.show(this, "working . . .", "performing HTTP post to del.icio.us"); final ResponseHandler<String> responseHandler = HTTPRequestHelper.getResponseHandlerInstance(this.handler); new Thread() { public void run() { HTTPRequestHelper helper = new HTTPRequestHelper(responseHandler); Use helper helper.performPost(URL_GET_POSTS_RECENT, for HTTP user, pass, null, null);
Barcode Drawer In .NET
Using Barcode creation for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Draw QR-Code In Java
Using Barcode drawer for Java Control to generate, create QR Code image in Java applications.
www.OnBarcode.com
} }.start();
PDF 417 Printer In Visual Studio .NET
Using Barcode creator for Reporting Service Control to generate, create PDF417 image in Reporting Service applications.
www.OnBarcode.com
Code 128 Maker In Java
Using Barcode printer for Eclipse BIRT Control to generate, create USS Code 128 image in Eclipse BIRT applications.
www.OnBarcode.com
Parse XML } String result private String parseXMLResult(String xmlString) { StringBuilder result = new StringBuilder(); try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); DeliciousHandler handler = new DeliciousHandler(); xr.setContentHandler(handler); xr.parse(new InputSource(new StringReader(xmlString))); List<DeliciousPost> posts = handler.getPosts(); for (DeliciousPost p : posts) { result.append("\n" + p.getHref()); } } catch (Exception e) { // log and or handle } return result.toString(); }
Printing 1D Barcode In VB.NET
Using Barcode generation for Visual Studio .NET Control to generate, create 1D image in .NET applications.
www.OnBarcode.com
Barcode Decoder In C#.NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
To use a POX service, we need to know a bit about it, beginning with the URL endpoint B. To call the Delicious service, we again use a Handler to update the UI C, and we use the HttpRequestHelper we previously built and walked through in the last
Web services
section. Again in this example, we have many fewer lines of code than if we didn t use the helper lines of code we d likely be repeating in different Activity classes. With the helper instantiated, we call the performRequest method with a username and password D. This method, via the helper, will log in to Delicious and return an XML chunk representing the most recently bookmarked items E. To turn the raw XML into useful types, we then also include a parseXMLResult method F. Parsing XML is a subject in its own right, and we ll cover it in more detail in chapter 13, but the short takeaway with this method is that we walk the XML structure with a parser and return our own DeliciousPost data beans for each record. That s it that s using POX to read data over HTTPS. Building on the addition of XML to HTTP, above and beyond POX, is the REST architectural principle, which we ll explore next.
REST
While we look at REST, we ll also try to pull in another useful concept in terms of Android development: working with the various Google GData APIs (http:// code.google.com/apis/gdata/). We used the GData APIs for our RestaurantFinder review information in chapter 3, but there we didn t authenticate, and we didn t get into the details of networking or REST. In this section, we ll uncover the details as we perform two distinct tasks: authenticate and retrieve a Google ClientLogin token and retrieve the Google Contacts data for a specified user. Keep in mind that as we work with the GData APIs in any capacity, we ll be using a REST-style API. The main REST concepts are that you specify resources in a URI form and you use different protocol methods to perform different actions. The Atom Publishing Protocol (AtomPub) defines a REST-style protocol, and the GData APIs are an implementation of AtomPub (with some Google extensions). As we noted earlier, the entire Intent approach of the Android platform is a lot like REST. A URI such as content://contacts/1 is in the REST style. It includes a path that identifies the type of data and a particular resource (contact number 1). That URI doesn t say what to do with contact 1, though. In REST terms, that s where the method of the protocol comes into the picture. For HTTP purposes, REST uses various methods to perform different tasks: POST (create, update, or in special cases, delete), GET (read), PUT (create, replace), and DELETE (delete). True HTTP REST implementations use all the HTTP method types and resources to construct APIs. In the real world, you ll find few true REST implementations. It s much more common to see a REST-style API. This kind of API doesn t typically use the HTTP DELETE method (many servers, proxies, and so on, have trouble with DELETE) and overloads the more common GET and POST methods with different URLs for different tasks (by encoding a bit about what s to be done in the URL, or as a header or parameter, rather than relying strictly on the method). In fact, though many people refer to the GData APIs as REST, they re technically only REST-like, not true REST. That s not necessarily a bad thing; the idea is ease of use of the API rather than pattern purity. All in all, REST is a popular architecture or style because it s simple, yet powerful.
Copyright © OnBarcode.com . All rights reserved.