Android Programming Tutorials: The Patchy Problem

Versions of this book before Version 2.1 — including the 1st Edition and 2nd Edition in print — have a Twitter client, named Patchy, as a sample application. Patchy uses Twitter's basic authentication when it accesses the Twitter REST API, whether directly (Tutorial #15) or via JTwitter (most of Tutorials #16-32). And life was wonderful.

Then, Twitter decided to add an OAuth option for authentication. This too was fine, as basic authentication still worked, and so Patchy was unaffected.

Then, in June 2010, Twitter stopped supporting basic authentication, thereby breaking Patchy.

Fortunately, there is identi.ca. The identi.ca service, powered by StatusNet, offers a very similar "microblogging" service to Twitter. It offers a (mostly) Twitter-compatible REST API, complete with support for basic authentication. Version 2.1 of this book switches Patchy over to use identi.ca instead of Twitter.

If you are a current Warescription subscriber, you can download Version 2.1. If, however, you either have one of the print editions, or you were a former Warescription subscriber, here is how you can patch Patchy to work with identi.ca:

  1. Download a newer, modified version of jtwitter.jar and put it in your project's libs/ directory
  2. In Tutorial #15, use https://identi.ca/api/statuses/update.json as the URL for your HTTP POST operation.
  3. In the getClient() method of all incarnations of the Patchy class, after you create the Twitter object via the constructor, add in a call to client.setAPIRootUrl("https://identi.ca/api");
  4. In the poll() method of all incarnations of the TwitterMonitor class, after you create the Twitter object via the constructor, add in a call to client.setAPIRootUrl("https://identi.ca/api");
  5. Use an identi.ca account, rather than a Twitter account, wherever Patchy asks for login credentials (e.g., via the preferences)

And that's it. You can see all of this in the source code for the Patchy samples, in the book's GitHub repository.

The author apologizes for the hassle this may cause you in your use of the book.