Android Programming Tutorials

(Romina) #1
Raising (Something Like) a Tweet


  • Add logic to check for the 140-character message limit before
    sending the request. If the message is too long, display an


AlertDialog.



  • Make the AlertDialog from the previous point obsolete by adding


the android:maxLength attribute to the EditText for the message, to
constrain it to 140 characters.


  • Add in TinyURL support by adding a field for a URL to append to


the end of the message, then using the TinyURL REST API
(http://tinyurl.com/api-create.php?url = ... returns the shortened

URL as a response) to generate the shortened URL, then attach it to
the message before making the request.


  • Experiment with the Android 2.2 AndroidHttpClient class, as an
    alternative to DefaultHttpClient.


Further Reading.........................................................................................


Additional examples of interacting with HttpClient from Android can be


found in the "Communicating via the Internet" chapter of The Busy Coder's


Guide to Android Development.


However, the definitive resource for HttpClient is the Apache site for


HttpClient itself. In particular, their samples show a number of techniques


we will not be using here.


163
Free download pdf