无法使用Facebook SDK共享图像



如果我删除此功能,我可以在Facebook上在Facebook上共享,例如" .setimageurl(imgtoshare)"

我的包装名称在构建imgToShare时正确,并且R.drawable.ic_launcher肯定存在。

这里有什么问题?我只想从可绘制的文件夹中分享图像。

public final void launchFacebook() {
    Uri imgToShare = Uri.parse("android.resource://com.mypackage.name/" + R.drawable.ic_launcher);
    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle("FocusON")
                .setContentDescription(
                        "Text to post to facebook")
                .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
                .setContentUrl(Uri.parse("https://www.myurl.com"))
                .setImageUrl(ResourceToUri(getApplicationContext(), R.drawable.ic_launcher))
                .setImageUrl(imgToShare)
                .build();
        shareDialog.show(linkContent);
    }
}

看起来像在Facebook上共享照片的工作与共享链接有所不同。我尚未测试以下测试,但是在阅读了他们的文档后,我认为应该这样的事情:

SharePhoto photo = new SharePhoto.Builder().
        .setImageUrl(imageToShare)
        .setCaption("text to post to facebook")
        .build();
SharePhotoContent content = new SharePhotoContent.Builder()
        .addPhoto(photo)
        .build();
shareDialog.show(content);

refs

https://developers.facebook.com/docs/sharing/android#photos

最新更新