Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image share from android to facebook?

Tags:

android

How i can share a image from from my app to facebook in android?

like image 961
mohammedsuhail Avatar asked Oct 22 '10 09:10

mohammedsuhail


People also ask

Why can't I post pictures on Facebook from my Android phone?

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.

Why can't I share photos from my phone to Facebook?

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.


2 Answers

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.

like image 153
Mathias Conradt Avatar answered Oct 09 '22 11:10

Mathias Conradt


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"));
like image 27
David Snabel-Caunt Avatar answered Oct 09 '22 10:10

David Snabel-Caunt