我正在尝试使用 Android 共享意图在 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 应用程序不接受我的消息(显示要发布的空白消息),但反之则不然。所以看起来该应用程序完全忽略了任何纯文本消息。我很害怕!这是 Facebook 应用程序中根本无法发布短信(具有分享意图)的主要错误吗?
我刚刚构建了这段代码,它对我有用:
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);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)