Android facebook: Do not show my message in a dialog box

I am working on a facebook android application, but there is one problem that I am facing

I am using the following Android / Java example
- Post plain text on a Facebook wall?

so the problem is that everything works fine, dialogs, etc., but when it opens the screen for loading Walla Message, which I installed here

        try 
        { 
            System.out.println("*** IN TRY ** ");
            Bundle parameters = new Bundle(); 
            parameters.putString("message", "this is a test");// the message to post to the wall 
            facebookClient.dialog(this, "stream.publish", parameters, this);// "stream.publish" is an API call 
        } 
        catch (Exception e) 
        { 
            // TODO: handle exception 
            System.out.println(e.getMessage()); 
        } 

This does not show me my message written in a dialog box. What is the problem with this

Can someone tell me please.

Thank you so much.

+5
source share
2 answers

Use this code, it works for me:

                    Bundle parameters = new Bundle();
                    parameters.putString("message",sharetext.getText().toString());// the message to post to the wall
                    //facebookClient.dialog(Jams.this, "stream.publish", parameters, this);// "stream.publish" is an API call
                    facebookClient.request("me/feed", parameters, "POST");

Hope this helps.

Edited:



 public class FacebookActivity implements DialogListener
    {

        private Facebook facebookClient;
        private LinearLayout facebookButton;



       public FacebookActivity(Context context) {

           facebookClient = new Facebook();
           // replace APP_API_ID with your own
           facebookClient.authorize(Jams.this, APP_API_ID,
               new String[] {"publish_stream", "read_stream", "offline_access"}, this);

       }

        @Override
        public void onComplete(Bundle values)
        {

            if (values.isEmpty())
            {
                //"skip" clicked ?

            }

            // if facebookClient.authorize(...) was successful, this runs
            // this also runs after successful post
            // after posting, "post_id" is added to the values bundle
            // I use that to differentiate between a call from
            // faceBook.authorize(...) and a call from a successful post
            // is there a better way of doing this?
            if (!values.containsKey("post_id"))
            {
                try
                {
                    Bundle parameters = new Bundle();
                    parameters.putString("message",sharetext.getText().toString());// the 

message to post to the wall
                    //facebookClient.dialog(Jams.this, "stream.publish", parameters, 

this);// "stream.publish" is an API call
                    facebookClient.request("me/feed", parameters, "POST");
                    sharetext.setText("");
                    Toast.makeText(Jams.this,"Message posted 

successfully.",Toast.LENGTH_SHORT).show();

                }
                catch (Exception e)
                {
                    // TODO: handle exception
                   // System.out.println(e.getMessage());
                }

            }

        }

        @Override
        public void onError(DialogError e)
        {       
            return;
        }

        @Override
        public void onFacebookError(FacebookError e)
        {   
            return;
        }

        @Override
        public void onCancel()
        {      
            return;     
        }

    }
0
source
+7

All Articles