My android application using facebook-android-sdk:4.14.0 to share a link. I used ShareLinkContent to create share content and call setImageUrl() to specify image. I want to use image from my app (not from a internet url link) to show on share post. I already tried as below code but it not work:
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("...")
.setContentDescription("...")
.setContentUrl(Uri.parse("https://...))
.setImageUrl(Uri.parse("file:///android_asset/ic_boxworldpro.png"))
.build();
shareDialog.show(linkContent);
} else {
Toast.makeText(MainMenuActivity.this, "Unable to Share...Try again.",
Toast.LENGTH_SHORT).show();
}
I also tried with image from drawable but the phenomenon was same
.setImageUrl(Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.ic_boxworldpro))
Anyone can help me !!
According to the document here
setImageUrl
should use a URL
, not a uniformed Uri
in Android platform.
a imageURL, the URL of thumbnail image that will appear on the post
Also the java docs of the library has clearly say A network URL of image
public ShareLinkContent.Builder setImageUrl(@android.support.annotation.Nullable android.net.Uri imageUrl)
Set the URL of a picture to attach to this content.
Parameters:
imageUrl - The network URL of an image.
Returns:
The builder.