Chapter 4
An Android Social Media App
In This Chapter
Posting on Twitter with Android code
Tweeting with your app on a user’s behalf
Areader 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: It posts a new tweet, and it gets 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");
Of course, these two statements only serve as a summary, and a summary is never the same as the material it summarizes. Imagine ...
Get Android Application Development All-in-One For Dummies, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.