我正在尝试使用 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/