0

I have a problem when using twitter4j, when I get timeline using this code :

try {
    ResponseList<Status> tweets = twitter.getHomeTimeline();
    for(Status s : tweets){
        Tweet temp = new Tweet(new URL(s.getUser().getProfileImageURL()),s.getUser().getName(),"@"+s.getUser().getScreenName() , s.getText());
        tweetsPanel.add(temp);
    }
} catch (TwitterException | MalformedURLException e) {
    e.printStackTrace();
}

(Tweet is local class) everything is OK except the retweets in the timeline are displayed as "Quote Retweet":

RT @SOMEONE : the tweet.

I want it like the website, just a normal retweet.

  • Check this previous question and answer: http://stackoverflow.com/questions/12256606/retweet-using-twitter4j-android – Pablo Lozano Apr 10 '13 at 14:16
  • @PabloLozano i dont want "How To retweet" , i want "how to display other's retweet" , Thanks :D –  Apr 11 '13 at 13:06

1 Answers1

0

on twitter4j the retweets are shown in format

RT @user : tweet

because is the actual form a rt takes in text. If you put on twitter a tweet with this same format it will be parsed as a normal retweet from twitter itself.

the only way you can edit this out is to parse the text and eliminate the first part manually. try something like:

String tweetText = "";
String [] splitted=s.getText().split(":");
if(splitted.lenght>2)
for (int i=1;i<splitted.lenght-1;i++)
{
  tweetText+=splitted[i]+":";
}
tweetText+=splitted[splitted.lenght-1];
return tweetText;

by starting the for on i=1 you will avoid adding the first split that contains the RT @user, by adding the splitted[i]+":" you will put back eventual other ":" present in the tweet that split will otherwise eliminate. Of course you don't want to introduce a ":" that was not there, so the last piece of splitted goes outside the for, without the +":"