facebook的Android共享 Intent -共享文本和链接

标签 android facebook android-intent share

我正在尝试使用 Android 分享 Intent 在 facebook 上发布一些内容。它看起来像这样:

shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Free education for all! http://linkd.in/xU8mCc");
startActivity(shareIntent);

所以我的帖子既有文字又有链接。但是当消息发布在facebook上时,它只有链接,没有消息。我尝试了各种附加功能,但没有任何效果。

有人遇到过这个问题并解决了吗?我有 facebook 应用程序版本 1.8.1

编辑:我尝试删除链接,但 Facebook 应用程序没有接收我的消息(显示要发布的空白消息),但反之则不然。所以看起来该应用程序完全忽略了任何纯文本消息。我吓坏了!这是FB应用程序中根本无法发布短信(具有共享 Intent )的主要错误吗?

最佳答案

我刚刚构建了这段代码,它对我有用:

private void shareAppLinkViaFacebook(String urlToShare) {
    try {
        Intent intent1 = new Intent();
        intent1.setClassName("com.facebook.katana", "com.facebook.katana.activity.composer.ImplicitShareIntentHandler");
        intent1.setAction("android.intent.action.SEND");
        intent1.setType("text/plain");
        intent1.putExtra("android.intent.extra.TEXT", urlToShare);
        startActivity(intent1);
    } catch (Exception e) {
        // If we failed (not native FB app installed), try share through SEND
        String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
        startActivity(intent);
    }
}

关于facebook的Android共享 Intent -共享文本和链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8771333/

相关文章:

android - gradle无法正常工作

facebook - 社会名流 laravel 5.4 Facebook 供应商

java - 使用 Intent 发送和接收 Arraylist?安卓

Android:从通知启动外部应用程序

java - 使用 Spring Security 登录 Facebook

android - 错误的 Intent 被使用

android - JobService 不会在 android 9 中重新安排

android - 将我的 TTS 引擎添加到像 SAPI 一样的 Android TTS 服务

android - 无法注册 native Android 应用程序

c# - Facebook C# SDK 文档和示例在哪里?