Adding content to Facebook feed dialog from Facebook SDK for Android

oriharel picture oriharel · Dec 15, 2010 · Viewed 15.4k times · Source

In my android app, I want users to "share" my app in their wall, so I want them to post a predefined content status on their wall.

How can I customize the wall status? (I want to add my app icon and some flare text).

Answer

Galip picture Galip · Dec 15, 2010

Download the Facebook SDK and import it in your project. Then use the following code to Authorize:

    public void sendtoFacebook(){
        facebookClient = new Facebook("<Your_APP_ID");
        facebookClient.authorize(<Current_class>.this, new AuthorizeListener());
    }

Now you have to add the following methodes:

class AuthorizeListener implements DialogListener {
    public void onComplete(Bundle values) {
        Bundle parameters = new Bundle();
            parameters.putString("message", "<Message_you_want_to_send>");// the message to post to the wall
            facebookClient.dialog(<Current_class>.this, "stream.publish", parameters, this);// "stream.publish" is an API call
    }
    @Override
    public void onFacebookError(FacebookError e) {
    }
    @Override
    public void onError(DialogError e) {
    }
    @Override
    public void onCancel() {
    }
}

Your Application name and Icon will automatically be added :)