在对类似帖子进行分组后,用户Feed上的帖子内容错误

时间:2013-10-08 11:37:34

标签: android facebook facebook-android-sdk

我的应用程序有一个启动Facebook网络对话框的按钮。登录后,该应用程序有一个对话框,用户可以写一些内容,当他点击“分享”按钮时,我们会代表他发布一个链接。

执行“分享”操作2到3次,在很短的时间内,Facebook将用户Feed上的类似内容分组,而不是显示正常内容,它显示的内容类似于附图中显示的内容。用户时间线是正常的。

我们使用以下实现发布链接:

Bundle postParams = new Bundle();
postParams.putString("name", getString(R.string.app_name));
postParams.putString("caption", getResources().getString(R.string.home));
postParams.putString("description", someDescription);
postParams.putString("message", someMessage);
postParams.putString("picture", a link to a picture);
postParams.putString("link", a link to open the page to download the app);


final Request request = new Request(this.session,
"me/feed", postParams, HttpMethod.POST);

request.setCallback(new Request.Callback() {
@Override
public void onCompleted(final Response response) {
final FacebookRequestError error = response.getError();

  if (error == null) {
   // Do something
  } else {
   switch (error.getErrorCode()) {
    case FEED_LIMIT:
     // Do something
    break;

    case DUPLICATE_MESSAGE:
     // Do something
    break;

    case MISSING_MESSAGE:
    // Do something
    break;

    case CONNECTION:
     // Do something
     break;

    default:
    // Do something
    break;
  }
}});


request.executeAsync();

My feed, after share same content in a short time.

我们只是这样做,我们可以重现并看到它发生。

希望有助于理解。

1 个答案:

答案 0 :(得分:0)

我不确切知道,但我认为这是同步问题。当您代表用户发布链接时,最好使用同步来尝试代码,或者您可以做的是在发送新请求之前保留一个标记以检查您之前的请求是否已完成。

方法1:使用synchronized关键字。

void post_request () {
    synchronized (request) {
        //post your link here and wait for your request completion.
    }
}

方法2:保持旗帜。

boolean is_request_in_process = false;

void post_request () {
      if (!is_request_in_process) {
           is_request_in_process = true;
           // post your request here and wait for confirmation.
           // after completion is_request_in_process = false;
      }
}

您还可以结合使用方法和检查:

Request request_obj = null;
boolean is_request_in_process = false;

    void post_request () {
        synchronized (request_obj) {
              if (!is_request_in_process) {
                   is_request_in_process = true;
                   // post your request here and wait for confirmation.
                   // after completion is_request_in_process = false;
              }
           }
        }

我不确定,但希望它可以帮助你。

相关问题