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

  • Home
  • SEARCH
  • 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 7918879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:39:38+00:00 2026-06-03T15:39:38+00:00

Hi i have integrated twitter in my android application.here the problem is when i

  • 0

enter image description here

Hi i have integrated twitter in my android application.here the problem is when i try to login to the twitter it should display a login dialog for the first time, it is displaying the dialog properly and i am able to login into twitter account,but at the second time i tried to login it displays a blank twitter dialog.below is my code for TwitterDialog calss. how can i resolve this issue.please give me a solution.

public class TwitterDialog extends Dialog {

    static final float[] DIMENSIONS_LANDSCAPE = { 460, 260 };
    static final float[] DIMENSIONS_PORTRAIT = { 280, 420 };
    static final FrameLayout.LayoutParams FILL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
    static final int MARGIN = 4;
    static final int PADDING = 2;

    private String mUrl;
    private TwDialogListener mListener;
    private ProgressDialog mSpinner;
    private WebView mWebView;
    private LinearLayout mContent;
    private TextView mTitle;

    private static final String TAG = "Twitter-WebView";

    public TwitterDialog(Context context, String url, TwDialogListener listener) {
        super(context);
        mUrl = url;
        mListener = listener;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mSpinner = new ProgressDialog(getContext());
        mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mSpinner.setMessage("Loading...");
        mContent = new LinearLayout(getContext());
        mContent.setOrientation(LinearLayout.VERTICAL);
        setUpTitle();
        setUpWebView();
        Display display = getWindow().getWindowManager().getDefaultDisplay();
        final float scale = getContext().getResources().getDisplayMetrics().density;
        float[] dimensions = (display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT: DIMENSIONS_LANDSCAPE;addContentView(mContent, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1]* scale + 0.5f)));
    }

    private void setUpTitle() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        Drawable icon = getContext().getResources().getDrawable(R.drawable.twitter_icon);
        mTitle = new TextView(getContext());

        mTitle.setText("Twitter");
        mTitle.setTextColor(Color.WHITE);
        mTitle.setTypeface(Typeface.DEFAULT_BOLD);
        mTitle.setBackgroundColor(0xFFbbd7e9);
        mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN);
        mTitle.setCompoundDrawablePadding(MARGIN + PADDING);
        mTitle.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
        mContent.addView(mTitle);
    }

    private void setUpWebView() {
        mWebView = new WebView(getContext());

        mWebView.setVerticalScrollBarEnabled(false);
        mWebView.setHorizontalScrollBarEnabled(false);
        mWebView.setWebViewClient(new TwitterWebViewClient());
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl(mUrl);
        mWebView.setLayoutParams(FILL);
        //mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        mContent.addView(mWebView);
    }

    private class TwitterWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (Constants.LOG)Log.d(TAG, "Redirecting URL " + url);
            if (url.startsWith(TwitterApp.CALLBACK_URL)) {
                mListener.onComplete(url);
                //mWebView.getSettings().setAppCacheEnabled(false);
                //mWebView.refreshDrawableState();
                if (Constants.LOG)Log.d(TAG, "Clearing chache");
                TwitterDialog.this.dismiss();
                return true;
            } else if (url.startsWith("authorize")) {
                return false;
            }
            return true;
        }
        @Override
        public void onReceivedError(WebView view, int errorCode,
            String description, String failingUrl) {
            if (Constants.LOG)Log.d(TAG, "Page error: " + description);
            super.onReceivedError(view, errorCode, description, failingUrl);
            mListener.onError(description);
            TwitterDialog.this.dismiss();
        }
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if(Constants.LOG)Log.d(TAG, "Loading URL: " + url);
            super.onPageStarted(view, url, favicon);
            mSpinner.show();
        }
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            String title = mWebView.getTitle();
            if (title != null && title.length() > 0) {
            mTitle.setText(title);
            }
            mSpinner.dismiss();
        }

    }
}``
  • 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-03T15:39:41+00:00Added an answer on June 3, 2026 at 3:39 pm

    You need to force login second time to resolve this issue,

    So just add the force_login=true in your twitter authorize url.

    I mean just change the below line of code in TwitterApp.java class (if you have a class file with different name then search in your project with DefaultOAuthProvider)

    mHttpOauthprovider = new DefaultOAuthProvider("http://twitter.com/oauth/request_token",
                    "http://twitter.com/oauth/access_token",
            "http://twitter.com/oauth/authorize?force_login=true");
    

    after adding force_login=true webview loading issue will be resolve but every time you need to enter login and password.

    I was stuck whole day to resolve this issue.

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

Sidebar

Related Questions

I have integrated Zxing library in my Android application, and it is Perfectly working,
I have successfully integrated Twitter Sharekit with my iPad application source. When I tested
I have integrated a Silverlight Navigation Application in an ASP.NET MVC web. However when
I have integrated Facebook using library in my previous application and it works fine
I am trying to make an application which integrates facebook and twitter. I have
I have integrated Twitter and Facebook in my iPhone App successfully. Also Facebook and
I have integrated this Jfreechart Bar Demo with my swing application. I have put
I have Integrated Cocos2d to my Windows based application. When I run my Project
I have integrated evernote in my application by downloading sample code from its site.
I want to integrate twitter in my android app. I have used twitter4j,jtwitter but

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.