O'Reilly logo

Java Programming for Android Developers For Dummies, 2nd Edition by Barry A. Burd

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 13

An Android Social Media App

IN THIS CHAPTER

check Posting on Twitter with Android code

check Tweeting with your app on a user's behalf

check Using Java exceptions to get out of a jam

A reader from Vancouver (in British Columbia, Canada) writes:

“Hello, Barry. I just thought I would ask that you include the area that seems to get attention from app developers: programs connecting with social sites. I look forward to reading the new book! Best regards, David.”

Well, David, you've inspired me to create a Twitter app. This chapter's example does two things: Post a new tweet and get a twitter user's timeline. The app can perform many more Twitter tasks — for example, search for tweets, look for users, view trends, check friends and followers, gather suggestions, and do lots of other things that Twitter users want done. For simplicity, though, I have the app perform only two tasks: tweet and display a timeline.

I can summarize the essence of this chapter's Twitter code in two short statements. To post a tweet, the app executes

twitter.updateStatus("This is my tweet.");

And, to display a user's timeline, the app executes

List<twitter4j.Status> statuses = twitter.getUserTimeline("allmycode"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required