[英]How to share picture or text from fragment to Facebook using android studio?
我尝试将 android studio 中片段的图片分享到 facebook
..... 该应用程序有很多片段,所以如果我按下“分享”,这个片段中的图片将在我的 Facebook 上分享,等等。
我使用 Intent 共享文本,但这不起作用:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, desc.getText().toString());
startActivity(Intent.createChooser(intent, "Share with"));
share(desc.getText().toString());
谢谢
试试这个参考:
: http ://simpledeveloper.com/how-to-share-an-image-on-facebook-in-android/ 希望它会帮助你。如果它工作接受我的回答
您可以使用 facebook sdk 尝试此操作。
private void shareFacebook(){
if (!ShareDialog.canShow(ShareLinkContent.class)) return;
ShareDialog dialog = new ShareDialog(this);
ShareLinkContent.Builder builder = new ShareLinkContent.Builder();
builder.setContentUrl(Uri.parse("FileSharingUrl"));
builder.setImageUrl(Uri.parse("image url"));
if (mSharePhotoosUrl) {
builder.setContentDescription("body description");
}
if (mShareCreator) {
builder.setContentTitle("title if any");
}
dialog.show(getActivity(), builder.build());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.