2

我正在尝试使用 facebook sdk 4.x 从我的应用程序中将纯文本共享给 messenger 应用程序,但我无法为此配置 contentUri,但是当我发送图像时它可以工作。

如何为纯文本执行此操作?

Uri contentUri = Uri.parse("android.resource://in.darpankulkarni.l33ttxtformessenger/mipmap/ic_launcher");
// contentUri points to the content being shared to Messenger
   ShareToMessengerParams shareToMessengerParams =
        ShareToMessengerParams.newBuilder(contentUri, "image/png").setExternalUri(Uri.parse("https://montanaflynn-l33t-sp34k.p.mashape.com/encode?text=Hello+How+the+hell+are+you!&mashape-key=AD8dVisiLdmshFoLegK2hzNoDQI4p1BDlshjsn50fOqenOnPY7"))
                        .build();

// Sharing from an Activity
   MessengerUtils.shareToMessenger(
                this,
                REQUEST_CODE_SHARE_TO_MESSENGER,
                shareToMessengerParams);

如何使用上述代码发送纯文本?

4

1 回答 1

2

支持的 MessengerUtils 方法不允许共享文本。以下对我有用:

ShareLinkContent.Builder shareLinkContentBuilder = new ShareLinkContent.Builder()
        .setContentTitle(contentTitle)
        .setContentDescription(contentDescription)
        .setContentUrl(Uri.parse(url));
shareLinkContentBuilder.setImageUrl(Uri.parse(imageUrl));
MessageDialog messageDialog = new MessageDialog(activity);
messageDialog.registerCallback(callbackManager, callback);
messageDialog.show(shareLinkContentBuilder.build());

分享链接内容来自:https ://developers.facebook.com/docs/sharing/android

于 2016-02-12T19:58:27.157 回答