0

I've set up Fabric and a log in button in Android Studio using the guide from the docs and now want to fetch the logged in user's twitter feed such as on the official app.

How do I implement this? The official docs mention using the REST API but don't show a way to add the homeTimeline to a GridView/ListView adapter..

Timmo
  • 2,266
  • 4
  • 34
  • 54
  • As @Elddir said in an answer: "You can use [Twitter libraries](https://dev.twitter.com/overview/api/twitter-libraries) to use the Twitter REST API. The Java library is [Twitter4J](http://twitter4j.org/en/index.html#introduction). Hope this helps." – SuperBiasedMan Jul 07 '15 at 15:24

1 Answers1

1

Even is an old question and hopefully you've found the solution, i post the answer as i think the Fabric Twitter Android Documentation i's a ____ Maybe this method i use can help you

public void getTweets(){
    TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
    twitterApiClient.getStatusesService().homeTimeline(null, null, null, null,null,null, null, new Callback <List<Tweet>>() {

        @Override
        public void success(Result<List<Tweet>> listResult) {
            tweets = listResult.data;
            final FixedTweetTimeline userTimeline = new FixedTweetTimeline.Builder()
                    .setTweets(tweets)
                    .build();
            adapter = new CustomTweetTimelineListAdapter(TimelineActivity.this, userTimeline);
            setListAdapter(adapter);
        }

        @Override
        public void failure(TwitterException e) {
            Log.d("Twitter","twitter " + e );
        }
    });
}
PereCullera
  • 177
  • 2
  • 12
  • Hi, I've tried to implement the method you've suggested here, but Android Studio gives me a lot of errors. I suspect that I've wrong to define CustomTweelineListAdapter. Can you post a complete source to retrieve the homeline from twitter using Fabric? – felice.murolo Aug 15 '16 at 09:15
  • Hi @felice.murolo, have you alrready followed the instructions for "Getting Started". Opened a free account and installed the Fabric Kid `Kits can be installed manually or using the Fabric IDE plugin for Android Studio or IntelliJ.`? https://docs.fabric.io/android/fabric/overview.html – PereCullera Aug 15 '16 at 09:54
  • Hi @pereCullera. Yes, I've already successfully implemented UserTimeline or SearchTimeline with Fabric plugin and Android Studio. Then I tried to implement the vision of Home_Timeline, so far without success. So, I need a full code example to get & display the HomeTimeline. – felice.murolo Aug 15 '16 at 10:12
  • Hope it helps, basically adapter get the Tweet Object from response and attach it to the UI https://ideone.com/bG4fcR – PereCullera Aug 15 '16 at 10:51
  • Hi @felice.murolo did it help you? – PereCullera Aug 15 '16 at 12:38
  • sorry for the delayed response, here in Italy is "Ferragosto", a national holiday in which we organize the barbecue with parents, relatives and friends. So I was late to respond, I'm sorry. Well, the link you sent me, it has served its purpose. The problem with Android Studio did not depend on incorrect definition of the adapter, but from StatusesService.homeTimeLine method. See next comment, pls. – felice.murolo Aug 15 '16 at 15:48
  • In the example that I found online, the last parameter to be passed to the method was the callback function. But this was true of the old definition of the method. In the new definition, it returns a Call > that should be used very differently. Now, thanks to your help, I managed to get the display of HomeTimeLine. When I have finished setting up a small application that gets the user's stream running log and allows the retweet and write a new tweet, I will insert the source on github and then I also will talk in this thread. So, for now, thanks very much. – felice.murolo Aug 15 '16 at 16:05
  • 1
    I've loaded on github a working demo app. If anyone is interested in, refer to https://github.com/felmur/TwitterTest/ – felice.murolo Aug 17 '16 at 17:31