Android twitter sdk using fabric Get public tweets

2019-07-26 12:53发布

问题:

Hello Guys I am facing a small trouble while working on twitter integration. I have used Fabric .

private void loadTweet(){
    final List<Long> tweetIds = Arrays.asList(510908133917487104L);
    TweetUtils.loadTweets(tweetIds, new Callback<List<Tweet>>() {

        @Override
        public void success(Result<List<Tweet>> result) {
            for (Tweet tweet : result.data) {
                tweeterLayout.setTweet(tweet);
            }
        }

        @Override
        public void failure(TwitterException e) {
            Log.v("Exception","TwitterException");
        }
    });

}

This method works fine for me if I pass a tweet ID. But I want to get public tweets of a particular user. any way around if I pass someone's ID ("@user_id") then I can fetch his tweets?

回答1:

Yes, you can retrieve a user's timeline.

String twitter_account = "jack";

final UserTimeline userTimeline = new UserTimeline.Builder()
    .screenName(twitter_account)
    .build();
final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(getActivity())
    .setTimeline(userTimeline)
    .build();

setListAdapter(adapter);