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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:19:46+00:00 2026-06-04T01:19:46+00:00

I have a facebook dialog in the screen in which I put a button

  • 0

I have a facebook dialog in the screen in which I put a button on the top right of the page (next to the Facebook`s login page). What I want to do is, if the user hits that button, dismiss the Facebook Dialog and pass some values for the activity that started the Facebook dialog (that is, the activity who called:

  mFacebook.authorize(this, Settings.FACEBOOK_PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());

The problem is that I only know how to dismiss the Facebook dialog WITHOUT BEING ABLE TO PASS ANY PARAMETERS TO IT, because the callback function onCancel() of the DialogListener doesnt receive a Bundle. I cant pass parameters back to the original activity (I could if the signature was onCancel(Bundle bundle) ).

In other words, what I want is either something like a onCancel(Bundle bundle) (which, unfortunately, doesn`t exist) or a way to programatically return to the callback onComplete(Bundle values) because, that way, I could read the Bundle values that I had set while the Facebook dialog was on the screen).

Thank you in advance!

Update (Code)

private class LoginDialogListener implements DialogListener {

    public void onComplete(Bundle values) {
        Settings.setFBStats(Settings.getFBStats() + 1);
        facebookPost();
        Util.showThanks(PhotoActivity.this, galleryName);
    }

    public void onFacebookError(FacebookError error) {
    }

    public void onError(DialogError error) {
    }

    public void onCancel() {
        System.out.println("Hi! =D");
    }
}





public void facebook(View target) {
    mFacebook = new Facebook( getString(R.string.facebookappid) );
    mAsyncRunner = new AsyncFacebookRunner(mFacebook);
    mAsyncRunner.logout(this, new LogoutRequestListener());
    mFacebook.authorize(this, Settings.FACEBOOK_PERMISSIONS,    Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());
}

And here is the code inside the FbDialog.java`s onCreate() method:

      @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSpinner = new ProgressDialog(getContext());
    mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mSpinner.setMessage("Loading...");

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    mContent = new FrameLayout(getContext());

    /* Create the 'x' image, but don't add to the mContent layout yet
     * at this point, we only need to know its drawable width and height 
     * to place the webview
     */
    createCrossImage();

    overlay = new ImageView(getContext());
    overlay.setImageDrawable(getContext().getResources().getDrawable(R.drawable.overlay_horiz));
    overlay.setTop(0);
    overlay.setLeft(0);
    overlay.setVisibility(View.INVISIBLE);

    /* Now we know 'x' drawable width and height, 
     * layout the webivew and add it the mContent layout
     */
    int crossWidth = mCrossImage.getDrawable().getIntrinsicWidth();
    setUpWebView(crossWidth / 2);


    /* Finally add the 'x' image to the mContent layout and
     * add mContent to the Dialog view
     */

    mContent.addView(mCrossImage, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    FrameLayout main = new FrameLayout(getContext());
    main.addView(overlay, new LayoutParams(1280, 755));

    RelativeLayout rel = new RelativeLayout(getContext());

    mContent.setPadding(450, 60, 0, 0);
    rel.addView(mContent, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    closeIt = new ImageButton(getContext());
    closeIt.setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.closefb));

    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(282, 150);
    lp.setMargins(980, 10, 0, 0);

    closeIt.setVisibility(View.INVISIBLE);
    closeIt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mListener.onCancel();
            FbDialog.this.hide();//HERE!!! =D
        }
    });

    rel.addView(closeIt,lp);

    main.addView(rel, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    addContentView(main, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}

The button that I am talking about is the closeIt button.

Do you see the setOnClickListener method of the closeIt button? So, I am only able to dismiss or hide the button. When I do any of that (dismiss or hide), the onCancel() method of the LoginDialogListener is called. The problem is that I cannot detect that it came from that button, because the flow also goes to that very same onCancel() method when the user presses de default X button next to the facebook dialog. If I am able to detect that it came from my button, then I can do some other things I want in the code.

Thank you once again.

  • 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-04T01:19:48+00:00Added an answer on June 4, 2026 at 1:19 am

    Change Facebook.DialogListener class and add a new onCancel(Bundle) function to it, (You may also change the existing onCancel() to onCancel(Bundle), but this should be avoided to maintain compatibility with the existing code.), then call onCancel(bundle) in onClick() of closeIt button.

    OR

    if LoginDialogListener is accessible in FbDialog then define a new function onCancel(Bundle) in it (You may use any Object instead of Bundle). Then in your onClick() of closeIt button, call

    closeIt.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                ...initialize_bundle...
                ((LoginDialogListener) mListener).onCancel(bundle);
                FbDialog.this.hide();//HERE!!! =D
            }
        });
    

    OR

    Define a new subclass of Facebook.DialogListener, Lets say it classA, having a new onCancel(Bundle) function. This classA should be visible to FbDialog. Now redefine your LoginDialogListener so that it is a subclass of classA. In your onClick() of closeIt button, call

    closeIt.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                ...initialize_bundle...
                ((classA) mListener).onCancel(bundle);
                FbDialog.this.hide();//HERE!!! =D
            }
        });
    

    Hope it helps !!

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

Sidebar

Related Questions

I think I have seen a Facebook photo selector dialog which allowed the user
I have facebook connect button on a page of my site and I want
User clicks on Login with facebook button, a popup is window dialog box is
I have facebook login setup in my android app. When the user clicks login
I am doing this in order to have Facebook like button in my page:
HI I have got Facebook Connect working with a functional login and logout button.
I have facebook iFrame app which is being displayed in company page. On same
I am developing an application which on login page also supports facebook login with
I have facebook login working on my website. But when users log in, the
I have a facebook app, in which I am opening my website's pages. I

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.