Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7697951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:07:44+00:00 2026-05-31T22:07:44+00:00

I am working on twitter integration with android using Twiitter4j. I am trying to

  • 0

I am working on twitter integration with android using Twiitter4j. I am trying to fetch Home timelines and its working fine. But when i am looking to get urls included in the tweets there is no functions. Is there a functon to get tweet entites like urls etc.

Here is the code

cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(Constants.CONSUMER_KEY)
            .setOAuthConsumerSecret(Constants.CONSUMER_SECRET)
            .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(
                    accessSecret);

    try {
        TwitterFactory factory = new TwitterFactory(cb.build());
        // gets Twitter instance with default credentials
        Twitter twitter = factory.getInstance();
        User user = twitter.verifyCredentials();
        List<Status> statuses = twitter.getHomeTimeline();
        System.out.println("Showing @" + user.getScreenName() + "'s home timeline.");
        for (Status status : statuses) {

            System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText() + "--"+status.getURLs()+ "--"+status.getURLEntities());
        }
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get timeline: " + te.getMessage());
        System.exit(-1);
    }

Works well with Sony’s code and after that i have moved my code to async task and it shows some errors

Here is my edited code

        protected String doInBackground(Void... args) {
        String response = null;

        try {
            TwitterFactory factory = new TwitterFactory(cb.build());
            // gets Twitter instance with default credentials
            Twitter twitter = factory.getInstance();
            User user = twitter.verifyCredentials();
            ResponseList<Status> statuses = twitter.getHomeTimeline();


            System.out.println("Showing @" + user.getScreenName() + "'s home timeline.");
            for (Status status : statuses) {

                System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText() + "--"+status.getUser().getProfileImageURL());
                URLEntity[] uent = status.getURLEntities();
                if (uent != null) {
                    for (int k = 0; k < uent.length; k++) {
                        Log.i("URL Entity", "Dp Url " + uent[k].getDisplayURL()
                                + " URL " + uent[k].getURL() + " start "
                                + uent[k].getStart() + " end "
                                + uent[k].getEnd());
                    }
}
            }

        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get timeline: " + te.getMessage());
            System.exit(-1);
        }
        return response;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:07:46+00:00Added an answer on May 31, 2026 at 10:07 pm

    You just need to add one more line while creating object of ConfigurationBuilder

    cb.setIncludeEntitiesEnabled(true);

    (Hint for the next code)And you will get the Entities then,

    ResponseList<Status> list = twitter.getHomeTimeline();
    URLEntity[] uent = list.get(0).getURLEntities();
    if (uent != null) {
                        for (int k = 0; k < uent.length; k++) {
                            Log.i("URL Entity", "Dp Url " + uent[k].getDisplayURL()
                                    + " URL " + uent[k].getURL() + " start "
                                    + uent[k].getStart() + " end "
                                    + uent[k].getEnd());
                        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get Twitter authentication working on my ASP.NET site. When you create
I'm using PECL OAuth with LinkedIn because it is working fine with Twitter and
I create topbar menu using twitter-bootstrap and It working fine .topbar .topbar-inner .container-fluid {{#view
I just began working on a little twitter-app using tweepy. is there any kind
Does anyone have a working example of OAuth authentication for twitter with Android? I
I am working on windows. I have built a twitter application using the twitter
text with apstrophe is not working in the twitter. Now i am using this
I'm working on mashup project on twitter with Google map but when tweet message
I'm working with a project that use Twitter API to get mentions timeline of
I'm working with twitter bootstrap 2.0.1 I'm trying to change the color of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.