0

我正在使用 facebook 默认对话框在我的 facebook 墙上分享帖子。我的代码如下。

facebook.dialog(this, "feed", new DialogListener() {

        @Override
        public void onFacebookError(FacebookError e) {
        }

        @Override
        public void onError(DialogError e) {
        }

        @Override
        public void onComplete(Bundle values) {
        }

        @Override
        public void onCancel() {
        }
    });

但现在我添加了一个 TextView 和一个 Button ,单击按钮后,textView 文本将发布在我的 Facebook 墙上。

4

1 回答 1

1

在您的DialogListener中覆盖onComplete()然后执行您想要的操作或使用getText从 textview 获取值并发布它。

public void onComplete(Bundle values) { 
            mProgress.setMessage("Posting ...");
            mProgress.show();

            AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);

            Bundle params = new Bundle();

            params.putString("message", "A Game Developed By Me !");
            params.putString("name", "Match Maker");
            params.putString("caption", "www.labmimosa.com/");
            params.putString("link", "https://play.google.com/store/apps/details?id=com.reverie.fushh");
            params.putString("description", "Dexter:  Blood. Sometimes it sets my teeth on edge, other times it helps me control the chaos.");
            params.putString("picture", "http://twitpic.com/show/thumb/6hqd44");
            //params.putByteArray("picture", bitMapData);

            mAsyncFbRunner.request("me/feed", params, "POST", new WallPostListener());
        }

Wallpostlistener 类是

private final class WallPostListener extends BaseRequestListener {
        public void onComplete(final String response) {
            mRunOnUi.post(new Runnable() {
                @Override
                public void run() {
                    mProgress.cancel();

                    Toast.makeText(Exp_Fb_Twt_Activity.this, "Posted to Facebook", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
于 2012-10-02T07:23:59.337 回答