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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:53:55+00:00 2026-06-06T14:53:55+00:00

I have made a sample for posting on Facebook using the basic Facebook library

  • 0

I have made a sample for posting on Facebook using the basic Facebook library provided at developer.facebook.com and it works just fine with SSO,

    btnPostOnFb.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
        {
                facebook.authorize(FBIntegrationSampleActivity.this, new String[]{ "user_photos,publish_checkins,publish_actions,publish_stream"}, new DialogListener() {
                    @Override
                    public void onComplete(Bundle values) {
                        if(values!=null && values.containsKey("access_token")){
                            postOnWall("NEW POST from" +count+"Android -Anuj");
                            Log.e("post on wall", "WALLPOST");
                            Toast.makeText(getApplicationContext(), "SUCCESSFULLY POSTED MSG ON WALL", Toast.LENGTH_SHORT).show();
                        }else if(values!=null)
                            Log.e("LOGINE SUCCESS", "LOGIN SUCCESS");
                            Toast.makeText(getApplicationContext(), "SUCCESSFULLY LOGGED IN", Toast.LENGTH_SHORT).show();
                    }
                    @Override
                    public void onFacebookError(FacebookError error) {
                        Log.e("onFBERROR", "ONFBERROR");
                    }
                    @Override
                    public void onError(DialogError e) {
                        Log.e("on DESI ERROR", "ON_ERROR");
                    }
                    @Override
                    public void onCancel() {
                        Log.e("onCANCEL", "ONCANCEL");
                    }
                });
            }
        }
    });

Which successfully posts on the Facebook wall, what i want is, I need to show the user that he has successfully signed in, and a message would be posted there after.

The Issue i face is the onComplete(Bundle values) method is called for both successful login and for successful post, how can i differentiate between both of them, is there a key in the Bundle values that can help to find the differnence?

Any suggestions are welcome.

  • 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-06T14:53:57+00:00Added an answer on June 6, 2026 at 2:53 pm

    Problem is that you are using for Authentication and Posting. No need to do like this :

    For Authentication use

    facebook.authorize(a, PERMISSIONS,-1,new LoginListener());
    

    And for posting :

    1) Without Dialog facebook.request(parameters)

    2) With Dialog

    facebook.dialog(this,"stream.publish",parameters,new TestUiServerListener());
    
    
        public class TestUiServerListener implements DialogListener {
        public void onComplete(Bundle values) {
            final String postId = values.getString("post_id");
            if (postId != null) {
                new AsyncFacebookRunner(ZValues.authenticatedFacebook).request(postId,new TestPostRequestListener());
            } else {
                Post_Message_Title.this.runOnUiThread(new Runnable() {
                    public void run() {
                    }
                });
            }
        }
    
        public void onCancel() {
        }
    
        public void onError(DialogError e) {
            e.printStackTrace();
        }
    
        public void onFacebookError(FacebookError e) {
            e.printStackTrace();
        }
    }
    
    public class TestPostRequestListener implements RequestListener {
        public void onComplete(final String response, final Object state) {
            try {
                JSONObject json = Util.parseJson(response);
                String postId = json.getString("id");
                this.runOnUiThread(new Runnable() {
                    public void run() { 
                            successLoginShowDialog();  // Dialog after Login succeeds
                    }
                });
            } catch (Throwable e) {
            }
        }
    
        public void onFacebookError(FacebookError e, final Object state) {
            e.printStackTrace();
        }
    
        public void onFileNotFoundException(FileNotFoundException e,
                final Object state) {
            e.printStackTrace();
        }
    
        public void onIOException(IOException e, final Object state) {
            e.printStackTrace();
        }
    
        public void onMalformedURLException(MalformedURLException e,
                final Object state) {
            e.printStackTrace();
        }
    }
    

    Just create a method successLoginShowDialog() and show whatever you want ,

    If Post is success , In TestPostRequestListener below Thread will be called , so do all stuffs in this Thread :

    this.runOnUiThread(new Runnable() {
            public void run() { 
                successLoginShowDialog();  // Dialog after Login succeeds
            }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a sample application which constructs a filter graph to capture audio
I have made the following sample user control: <UserControl x:Class=DLSAdministration.Controls.CombinedTextBoxControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
So I have made a simple site for a friend using codeigniter and grocery
I have started using jQuery and rails. I have made a simple form that
I have made a sample.sql database with SQL Lite Manager. How can I access
I have made a sample page, which has a logo page. It asks the
I have made a sample application in which I am able to implement help
I've made a simple app for the purpose of posting to a Facebook Page
I have made one sample project which can add and edit records from SQLite

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.