【问题标题】:Sharing Pictures and Text with Facebook SDK 4.2使用 Facebook SDK 4.2 共享图片和文本
【发布时间】:2015-06-25 09:52:17
【问题描述】:

我正在尝试使用 Facebook SDK 4.2 共享图片和文本,但是当我调用共享功能(通过 SDK 或意图)时,我得到的只是没有文本的图像。 这是代码

  Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
  shareIntent.setType("image/*");
  shareIntent.putExtra(Intent.EXTRA_STREAM,   Uri.parse("file://" + mFilepath));
  shareIntent.putExtra(Intent.EXTRA_TEXT,"example");
  shareIntent.setPackage("com.facebook.katana");
  startActivity(shareIntent);

【问题讨论】:

    标签: android facebook android-intent sdk publish


    【解决方案1】:

    Facebook 不允许预先填写消息。 详情请见this discussion

    【讨论】:

      【解决方案2】:

      试试这个

      // By this method we can post on facebook.
      private void publishFeedDialog() {
           Session session = Session.getActiveSession();
           //if(session==null)
           {                      
                  // try to restore from cache
                  session = Session.openActiveSessionFromCache(dashBoard);
              }
          Bundle params = new Bundle();
          params.putString("name", "MeetMeUp");
          params.putString("caption", "Discover events nearby, easily create events and invite your friends!");
          params.putString("description", "Finding, creating and sharing activities you’re passionate about are made easy with MeetMeUp. Whether you’re organizing a small gathering with friends, looking for a neighborhood football game or going to a local music concert, MeetMeUp makes it happen. ");
          params.putString("link", "https://play.google.com/store/apps/details?id=com.meetmeup.activity");
          params.putString("picture", "http://72.167.41.165/meetmeup/webservices/images/aaaaa-05.jpg");
      
          WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(getActivity(),session, params)).setOnCompleteListener(
                  new OnCompleteListener() {
      
                      @Override
                      public void onComplete(Bundle values, FacebookException error) {
                          if (error == null) {
                              // When the story is posted, echo the success
                              // and the post Id.
                              final String postId = values.getString("post_id");
                              if (postId != null) {
                                  Toast.makeText(getActivity(), "Posted story, id: " + postId, Toast.LENGTH_SHORT).show();
                              } else {
                                  // User clicked the Cancel button
                                  Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                              }
                          } else if (error instanceof FacebookOperationCanceledException) {
                              // User clicked the "x" button
                              Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                          } else {
                              // Generic, ex: network error
                              Toast.makeText(getActivity().getApplicationContext(), "Error posting story", Toast.LENGTH_SHORT).show();
                          }
                      }
      
                  }).build();
          feedDialog.show();
      }
      

      【讨论】:

      • Shahid,请问我可以知道我必须为会话导入什么包吗?有 4 种不同的解决方案
      • 哪一门课?能具体说明一下吗?
      • 私人无效 publishFeedDialog() { 会话会话 = Session.getActiveSession(); //if(session==null) { // 尝试从缓存中恢复 session = Session.openActiveSessionFromCache(dashBoard);我找不到修复会话和仪表板的方法,它说我必须导入它们,但是这样做,我总是会出错
      • 请用您的活动替换 dashBoard
      • 做到了,但我总是遇到会话问题。是否打算作为 Facebook 会话?
      【解决方案3】:

      请检查下面的代码它可能对你有帮助。

      Bundle parameters = new Bundle();
      parameters.putString("message", category_item_name_desc.getText().toString());
      parameters.putString("picture", categoryItemsModel.getImageUrl());
      parameters.putString("caption", txtDescription_desc.getText().toString());
      facebook.request("/me/feed", parameters, "POST");
      

      【讨论】:

      • 它很容易只发布图片
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-04
      相关资源
      最近更新 更多