Getting tweets with a specific hashtag from a custom timeline using Fabric in android
I am trying to get tweets with a specific hashtag from a custom timeline (ex-t20>) using Fabric in android.
I can get tweets from %23suman
(# suman) using the code below. But I want to receive tweets from %40kkajnabi%23suman
(@kkajnabi # suman).
public class TimelineActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timeline);
TwitterAuthConfig authConfig = new TwitterAuthConfig("xxxxxxbbbbwdqddq", "eieuhquifhioqhfiohqoifhoi");
Fabric.with((this), new TwitterCore(authConfig), new TweetUi());
final SearchTimeline searchTimeline = new SearchTimeline.Builder()
.query("%40kkajnabi%23suman")
.build();
I think this approach is wrong. Any plz help me write a request for %40kkajnabi%23suman
or is there some other approach for this.
source to share
It's a little rough, but here's how to get custom tweets
ArrayList<Tweet> tweets = new ArrayList<>();
TwitterCore.getInstance().getApiClient(session).getStatusesService()
.userTimeline(null,
"screenname",
10 //the number of tweets we want to fetch,
null,
null,
null,
null,
null,
null,
new Callback<List<Tweet>>() {
@Override
public void success(Result<List<Tweet>> result) {
for (Tweet t : result.data) {
tweets.add(t);
android.util.Log.d("twittercommunity", "tweet is " + t.text);
}
}
@Override
public void failure(TwitterException exception) {
android.util.Log.d("twittercommunity", "exception " + exception);
}
});
Then what I would do is a quick condition to determine if the Tweet object contains the hashtags you want from the objects attribute. I need to play around a bit to give you the exact answer you need. I looked at the API, unfortunately there are no arguments I can find for getting a custom timeline and then filtering by tag. So I think you will need to iterate. Here's a good link to the userTimeline () method of the StatusesService class https://twittercommunity.com/t/android-usertimeline-question/30263/2
Again, I'll update this answer when I get a chance later today
source to share