Inam
Inam

Reputation: 23

Android: How to share image on facebook via intent?

We previously used to post image on facebook like this...

Uri imageUri = getImageUri()
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
intent.setType("image/*");
intent.setPackage("com.facebook.katana");
startActivity(intent);

But now the image doesn't get attached to the newsfeed post. It shows a toast saying: "Unable to share to Reels. To share this content, create a post"

Any help will be appreciated.

Upvotes: 1

Views: 318

Answers (1)

Supertommino
Supertommino

Reputation: 582

You should use the Facebook sdk.

Bitmap image = ...
SharePhoto photo = new SharePhoto.Builder()
        .setBitmap(image)
        .build();
SharePhotoContent content = new SharePhotoContent.Builder()
        .addPhoto(photo)
        .build();

Documentation: https://developers.facebook.com/docs/sharing/android

Upvotes: 1

Related Questions