【问题标题】:Shared content does not display when sharing to Facebook分享到 Facebook 时不显示分享的内容
【发布时间】:2014-03-22 00:28:30
【问题描述】:

我实现了这段代码来将一些文本分享给不同的应用和社交网络:

btnShare.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent sharingIntent = new Intent(Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            String sharingText = "This is the text I want to share";

            sharingIntent.putExtra(Intent.EXTRA_TEXT, sharingText);
            startActivity(Intent.createChooser(sharingIntent,"Share using"));
        }
    });

我在 gmail、twitter、evernote、message 等所有应用程序上都能正常工作。但是,如果我选择使用 Facebook 分享,它会打开 facebook 应用程序,但内容是空白的。

有人对此有任何想法吗?

提前致谢。

【问题讨论】:

    标签: android facebook android-intent share


    【解决方案1】:

    是的,为了在 facebook 中分享您的数据,您必须使用 facebook API, 在这个链接Facebook Developers你会发现官方文档非常详细

      public void postToWall(String message){
        Bundle parameters = new Bundle();
                parameters.putString("message", message);
                parameters.putString("description", "topic share");
                try {
                    facebook.request("me");
            String response = facebook.request("me/feed", parameters, "POST");
            Log.d("Tests", "got response: " + response);
            if (response == null || response.equals("") ||
                    response.equals("false")) {
                showToast("Blank response.");
            }
            else {
                showToast("File posted to your facebook wall!");
            }
            //finish();
        } catch (Exception e) {
            showToast("Failed to post to wall!");
            e.printStackTrace();
            finish();
        }
    }
    

    【讨论】:

    • 你能解释一下你提供的代码吗?我不是很明白。那是来自 Facebook 的外部库吗?我看到了类似 facebook.request...
    • 您好,抱歉稍后再回复。我最近两周太忙了。今天我继续致力于这个功能。你能告诉我如何使用 Android Studio 设置 sdk 吗?我已阅读您发送的链接,但似乎仅适用于 Eclipse。
    猜你喜欢
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    相关资源
    最近更新 更多