Ram Chandran Ram Chandran -4 years ago 115
Android Question

share Image and text in Android

I'm using the code below to share Image and text in Android. When I choose Whatsapp it shares the image and text together , but when I choose Facebook it just shares Image without any text! What's mistake in my code? Thanks.

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(bitmapPath)));
share.putExtra(Intent.EXTRA_TEXT, "Shared via" + APP_URL);
startActivity(Intent.createChooser(share, "Share Image"));

Answer Source

What's wrong in my code?

Probably nothing. ACTION_SEND supports either EXTRA_TEXT or EXTRA_STREAM in one Intent, not both ("...can have either a EXTRA_TEXT or EXTRA_STREAM field, containing the data to be sent"). Some ACTION_SEND implementations will go beyond the documented protocol and try to use both. Others will stick with the documented protocol and only use one. In this case, Facebook perhaps chose to stick with the documented protocol and only use one.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download