繁体   English   中英

我想在我的Android应用程序中添加“将图片共享到Facebook”功能吗?

[英]i want to add “share the image to Facebook” feature in my android application?

我创建了一个向用户显示图像的应用程序。 用户可以下载图像并将其设置为墙纸,但我希望该用户可以将图像共享到Facebook? 我不知道该怎么做。 谁能帮我?

谢谢

使用Intent在Facebook中共享您的图像。

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = null;
if(imageUri!=null){
    screenshotUri = Uri.parse(imageUri);
    sharingIntent.setType("image/jpeg");
    sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
}
startActivity(Intent.createChooser(sharingIntent, "Share image using..."));

确保您的Image Uri不为null。 这将启动一个Intent,该Intent将显示您可以与之共享图像的所有应用程序。 其中,Facebook。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM