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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:34:38+00:00 2026-05-30T06:34:38+00:00

Is it possible to somehow retrieve the pin code from WebView in Android while

  • 0

Is it possible to somehow retrieve the pin code from WebView in Android while authorising the Twitter?

I’ve got tutorial example, but to login user need to rewrite the pin code from WebView to app. I just want to pass this and get pin code directly from web.

This is very similar to how it goes on iPhone.

Now I using something like this:

public void getTwitter() 
{
      handleEvent.post(new Runnable() 
      {

       @Override
       public void run() 
       {               
            if (oHelper.hasAccessToken()) 
            {

                oHelper.configureOAuth(twitterConnection);
                try 
                {
                     twitterConnection.updateStatus("Hii!!!!");
                } 
                catch (TwitterException e) 
                {
                     Log.d("TWEET", "Error Updating status " + e.getMessage());
                     e.printStackTrace();
                }
            } 
            else 
            {
                 try 
                 {
                      twitterConnection.setOAuthConsumer(CONSUMER_KEY,CONSUMER_SECRET);
                      requestToken = twitterConnection.getOAuthRequestToken("");
                      webViewDialog(requestToken.getAuthorizationURL(), 0);
                 } 
                 catch (TwitterException e) 
                 {
                     e.printStackTrace();
                 }
            }
       }

      });
}

then display the webview inside dialog popup:

private void webViewDialog(final String authorizationURL, final int type) 
{
      LinearLayout container = new LinearLayout(this);
      container.setMinimumWidth(200);
      container.setMinimumHeight(320);
      webView = new WebView(this);

      webView.setMinimumWidth(200);
      webView.setMinimumHeight(380);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.setWebViewClient(new WebViewClient());
      webView.loadUrl(authorizationURL);

      container.addView(webView);
      webDialog = new AlertDialog.Builder(this);
      webDialog.setView(container).setPositiveButton("Ok", new DialogInterface.OnClickListener() 
      {

         @Override
         public void onClick(DialogInterface dialog, int which) 
         {
             dia = dialog;
              if (type == 0) 
              {
                   twitterPinCodeDialog();
              }

         }
      }).show();
}

and in the end prompt user to input pincode:

public void twitterPinCodeDialog() 
{
      LinearLayout pinHolder = new LinearLayout(this);
      pinHolder.setGravity(Gravity.CENTER);
      final EditText editPinCode = new EditText(this);
      editPinCode.setGravity(Gravity.CENTER);
      editPinCode.setHint("Pin Code");
      editPinCode.setWidth(200);
      pinHolder.addView(editPinCode);

      Builder pinBuilder = new AlertDialog.Builder(this);
      pinBuilder.setView(pinHolder).setTitle("Twitter Pin Code Entry")
        .setMessage("Please enter displayed twitter code into the field")
        .setPositiveButton("Ok", new DialogInterface.OnClickListener() 
        {

         @Override
         public void onClick(DialogInterface dialog, int which) 
         {
              if (editPinCode.getText().toString() != null && !editPinCode.getText().toString().equals("")) 
              {
                   try 
                   {
                        accessToken = twitterConnection.getOAuthAccessToken(requestToken,editPinCode.getText().toString());
                        oHelper.storeAccessToken(accessToken);
                        Log.i("Access Token:", accessToken.getToken());
                        Log.i("Access Secret:", accessToken.getTokenSecret());
                        twitterConnection.updateStatus("Tweeted Successfully");
                   } 
                   catch (TwitterException te) 
                   {
                        if (401 == te.getStatusCode()) 
                        {
                            System.out.println("Unable to get the access token.");
                        } 
                        else 
                        {
                            te.printStackTrace();
                        }
                   }
              } 
              else 
              {
               Toast.makeText(context, "Pin code is required",
                 Toast.LENGTH_SHORT).show();
               dialog.dismiss();    
               dia.dismiss();
               twitterPinCodeDialog();
               }
         }

        }).setNegativeButton("Cancel",new DialogInterface.OnClickListener() 
        {

           @Override
           public void onClick(DialogInterface dialog,int which) 
           {
                Toast.makeText(context,"To share your news please complete login next time",Toast.LENGTH_LONG).show();
                dialog.dismiss();
           }
          }).show();
     }

I don’t even remember from where I took this example.
But it would be nice to get rid off last dialog.

  • 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-30T06:34:40+00:00Added an answer on May 30, 2026 at 6:34 am

    Yes it is quite possible – I don’t have my code in front of me, but the process is as follows:

    • When you make your twitter authorisation request, you provide it with a callback URL, lets call it callback://myapp.twitter.pin
    • Register a URL handler in your manifest for this URL
    • When the authorisation is successful, the twitter webpage will redirect the user to your callback URL
    • Android will intercept the callback URL and resume your login activity
    • You can use your onResume to access the PIN from the uri as I demonstrate in my question here
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while debugging a C++ program with GDB, is it possible somehow to add comments
Is it possible to retrieve variable set in onreadystatechange function from outside the function?
Though I've never heard of this but, is it possible to retrieve a node
Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like
Is it possible somehow to ask the user to allow cross-domain access instead of
is it somehow possible to call a rails function or to access a rails
Is it somehow possible on Swing to set a TitledBorder transparent so that a
Is it somehow possible to customize or subclass System.Windows.Forms.ColorDialog to add a few buttons?
Is it somehow possible to use the 'With' keyword on an existing object? I
Is it somehow possible to identify unused variables in a PHP file in Emacs?

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.