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 8529313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:00:29+00:00 2026-06-11T09:00:29+00:00

I’m trying to login on twitter from my android app using Twitter4j library but

  • 0

I’m trying to login on twitter from my android app using Twitter4j library but it crashes when the callback is called… and appears this screen: the page is not disponible

this is my code:

        public class TwitterLogin extends Activity {
    /** Called when the activity is first created. */

    Twitter twitter;
    RequestToken requestToken;

    /*
    * Calls the OAuth login method as soon as its started
    */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    //      setContentView(R.layout.main);
            OAuthLogin();
        }

    /*
    * - Creates object of Twitter and sets consumerKey and consumerSecret
    * - Prepares the URL accordingly and opens the WebView for the user to provide sign-in details
    * - When user finishes signing-in, WebView opens your activity back
    */
        void OAuthLogin() {
            try {
                twitter = new TwitterFactory().getInstance();
                twitter.setOAuthConsumer(TwitterConstants.CONSUMER_KEY,TwitterConstants.CONSUMER_SECRET_KEY);
                requestToken = twitter.getOAuthRequestToken(TwitterConstants.CALLBACK_URL);
                Log.w("TwitterLogin requestToken callbackUrl: "+requestToken.toString());
    //          requestToken = twitter.getOAuthRequestToken(OAuth.OUT_OF_BAND);
    //          String pin = requestToken.getParameter(OAuth.OAUTH_VERIFIER);
                String authUrl = requestToken.getAuthenticationURL();
                Log.w("TwitterLogin requestToken authUrl: "+authUrl);
                this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
                Log.w("TwitterLogin despres del startActivity intent");
                } catch (TwitterException ex) {
                Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
                Log.e("in Main.OAuthLogin", ex.getMessage());
            }
        }


    /*
    * - Called when WebView calls your activity back.(This happens when the user has finished signing in)
    * - Extracts the verifier from the URI received
    * - Extracts the token and secret from the URL
    */
        @Override
        protected void onNewIntent(Intent intent) {
            super.onNewIntent(intent);
            Log.w("TwitterLogin  dintre del onNewIntent");
            Uri uri = intent.getData();

            Log.w("TwitterLogin uri: "+uri.toString());

                if (uri != null && uri.toString().startsWith(TwitterConstants.CALLBACK_URL)){

                    try {
                        String verifier = uri.getQueryParameter("oauth_verifier");
                        Log.w("TwitterLogin","onNewIntent oauth_verifier: "+verifier);
                        AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier);
                        Log.w("TwitterLogin","onNewIntent accesToken: "+accessToken.toString());
                        String token = accessToken.getToken(), secret = accessToken.getTokenSecret();
                        displayTimeLine(token, secret); //after everything, display the first tweet

                    } catch (TwitterException ex) {
                        Log.e("Main.onNewIntent", "" + ex.getMessage());
                    }
                }

        }

    /*
    * Displays the timeline's first tweet in a Toast
    */

        @SuppressWarnings("deprecation")
        void displayTimeLine(String token, String secret) {
            if (null != token && null != secret) {
                List<Status> statuses = null;
                try {
                    twitter.setOAuthAccessToken(token, secret);
                    statuses = twitter.getFriendsTimeline();
                    Toast.makeText(this, statuses.get(0).getText(), Toast.LENGTH_LONG)
                    .show();
                } catch (Exception ex) {
                    Toast.makeText(this, "Error:" + ex.getMessage(),
                    Toast.LENGTH_LONG).show();
                    Log.d("Main.displayTimeline",""+ex.getMessage());
                }

            } else {
                Toast.makeText(this, "Not Verified", Toast.LENGTH_LONG).show();
            }
        }
    }

if someone can help me please, I’ve been trying to login on Twitter 2 days and I don’t know how to solve this.

Thanks

  • 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-06-11T09:00:30+00:00Added an answer on June 11, 2026 at 9:00 am

    have you provided callback URL for your app when registering you app on twitter.?

    if you have provide callback URL then use same in android client…

    because you are making request with callback

    requestToken = twitter.getOAuthRequestToken(TwitterConstants.CALLBACK_URL);

    then server also replies with callback after login is successful to twitter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.