How i can share a image from from my app to facebook in android?
Make sure that you have a strong Wi-Fi or network connection. Try uploading the original photo instead of an edited version. Check the size of the photo. We recommend uploading photos under 15MB.
Go to Settings > Apps & notifications > Facebook > Storage & cache on your device. Tap Clear storage and then Clear cache. Open the Facebook app and see if you can upload a photo.
public void shareOnFacebook() {
Uri uri = Uri.parse("http://m.facebook.com/sharer.php?u=" +
website_url + "&t="+ someTitle.replaceAll(" ","+");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
where your website should hold a meta tag like
<link rel="image_src" type="image/jpeg" href="http://www.domain.com/someimage.jpg" />
which will then be used on Facebook as the promo image. Of course this can also be done dynamically on server side.
This is the approach where you use an image that's also on a server somewhere already, so you don't need to send it from your Android device to a server first. Depending on your use case, but this is usually the easiest way.
You could achieve this using the Facebook SDK for Android.
A better way is to allow your user to share images using a service of their choice. Android can automatically present a list of apps which can handle images for you. Simply state that you have an image to send somewhere:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/path/to/image.ext"));
startActivity(Intent.createChooser(share, "Share Image"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With