我正在尝试使用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);
如何使用上面的代码发送纯文本?
答案 0 :(得分:2)
The supported MessengerUtils methods don't allow for sharing text. The following worked for me:
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());
The share link content was obtained from: https://developers.facebook.com/docs/sharing/android