Can't use image with Facebook SDK

I can share to Facebook using the following function if I remove it as " .setImageUrl (imgToShare) "

My package name is correct when created imgToShare

, and it R.drawable.ic_launcher

definitely exists as well .

What could be the problem? I just want to share an image with my accessible folder.

public final void launchFacebook() {
    Uri imgToShare = Uri.parse("android.resource://" + R.drawable.ic_launcher);

    if (ShareDialog.canShow(ShareLinkContent.class)) {

        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                        "Text to post to facebook")
                .setImageUrl(ResourceToUri(getApplicationContext(), R.drawable.ic_launcher))



source to share

1 answer

It looks like Facebook photo sharing works a little differently than link exchange. I haven't tested the following, but after reading their docs I think it should be something like this:

SharePhoto photo = new SharePhoto.Builder().
        .setCaption("text to post to facebook")

SharePhotoContent content = new SharePhotoContent.Builder()





All Articles