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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:24:36+00:00 2026-06-15T10:24:36+00:00

I was trying out codes from Android Twitter oAuth Connect Tutorial and it worked

  • 0

I was trying out codes from Android Twitter oAuth Connect Tutorial and it worked successfully. I tried to change the twitter authorization page to run in a WebView instead of a web browser but the WebView couldn’t seem to load url with this format oauth://twittersample which is the link back to my application. Upon successful authorization, the webview should close and return to my app successfully.

There is an error saying “The web page at oauth://twittersample?oauth_token=…. might be temporarily down or it may have moved permanently to a new web address”. What should I do?

This is the snippet to my WebView that is in my onCreate

WebView myWebView = (WebView)findViewById(R.id.myWebView);

    myWebView.setWebViewClient(new WebViewClient()
    {
    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, String url)
    {
     if (url != null && url.startsWith("oauth://twittersample"))
      //handleTwitterCallback(url);
     {
        System.out.println("TWEET TWEET TWEET");    
        webView.loadUrl(url);
        return true;

        }

     else

     return false;
    }
    }); 

This is the link to my Twitter java class TWITTER CONNECT CLASS
And this is my manifest

<activity android:name="com.test.settings.ShareSettings" android:label="ShareSettings" android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden">       
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="oauth" android:host="twittersample"/>
        </intent-filter>
    </activity>

Attached is the logcat when successfully run in browser

enter image description here

  • 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-15T10:24:37+00:00Added an answer on June 15, 2026 at 10:24 am

    I finally get it to work. I think earlier it did not work because I did not retrieve access token into the WebView.

    In my WebView under onCreate i did this

    myWebView = (WebView)findViewById(R.id.myWebView);
        myWebView.setWebViewClient(new WebViewClient()
        {
        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String url)
        { if (url != null && url.startsWith(TWITTER_CALLBACK_URL))
    
         { System.out.println("TWEET TWEET TWEET");
            retrieveAccessToken(url); //added this
            webView.setVisibility(View.GONE); //added this
            return true;            
            }
    
         else
    
         return false;
    
        }
        }); 
    

    and in my retrieveAccessToken(url) i have this.

    private void retrieveAccessToken(final String url)
    {
        Uri uri = Uri.parse(url);
        String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER);
    
        try {
            // Get the access token
            AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier);
    
            // Shared Preferences
            Editor e = mSharedPreferences.edit();
    
            // After getting access token, access token secret
            // store them in application preferences
            e.putString(PREF_KEY_OAUTH_TOKEN, accessToken.getToken());
            e.putString(PREF_KEY_OAUTH_SECRET,accessToken.getTokenSecret());
            // Store login status - true
            e.putBoolean(PREF_KEY_TWITTER_LOGIN, true);
            e.commit(); // save changes
    
            Log.e("Twitter OAuth Token", "> " + accessToken.getToken());
    
            TextView twitterConnect = (TextView) findViewById(R.id.twitterConnect);
            String disconnect = "Disconnect";
            twitterConnect.setText(disconnect);                                                     
    
            // Getting user details from twitter
            // For now i am getting his name only
            long userID = accessToken.getUserId();
            User user = twitter.showUser(userID);
            String username = user.getName();
    
            txtUpdate.setVisibility(View.VISIBLE);
            btnUpdateStatus.setVisibility(View.VISIBLE);
    
            // Displaying in xml ui
            //twitterUser.setText(Html.fromHtml("<b>Welcome " + username + "</b>"));
            TextView twitterUser = (TextView) findViewById(R.id.twitterDesc);     
            twitterUser.setText(Html.fromHtml(username));
            Toast.makeText(getApplicationContext(), "LOGGED IN AS " + username, Toast.LENGTH_LONG).show(); 
        } catch (Exception e) {
            // Check log for login errors
            Log.e("Twitter Login Error", "> " + e.getMessage());
        }
    }
    

    I got this to work exactly how I wanted it and logged in successfully.
    Do correct me if I’m doing anything wrong here.

    Thank you @user1690588 and @Nikolay Elenkov, for your time to help me out. 🙂

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

Sidebar

Related Questions

I'm trying to figure out how to POST JSON from Android by using HTTPClient.
I'm trying to login on twitter from my android app using Twitter4j library but
I'm trying out the AndroidAsyncHttp library for Android downloaded from http://loopj.com/android-async-http/ and am trying
I'm trying to implement OAuth for Google, Twitter, Yahoo etc. on Android using the
I'm trying to find out where this function comes from. Any one have any
I am trying to figure out what the below syntax do. It's code from
I am trying to send the Direct messages from my Android app. For that
I'm trying to send data from my Android app to my PC over TCP.
In some code we're trying out, coming from various tutorials, we end up missing
I am trying to send a pdf as an attachment from Android. Here is

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.