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://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);
}
}
+3
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().
.setImageUrl(imageToShare)
.setCaption("text to post to facebook")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
Refs
0
source to share