user2802764 user2802764 - 1 year ago 222
Android Question

Share image and text through Whatsapp or Facebook

I have in my app a share button and i want to share an image and a text at the same time. In GMail works fine but in WhatsApp only sent the image and in Facebook the app crashes. I've been searched by the web and apparently it is impossible to do or I have not looked well.

The code i use to share is this:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Message");

Uri uri = Uri.parse("android.resource://" + getPackageName() + "/drawable/ford_focus_2014");
try {
InputStream stream = getContentResolver().openInputStream(uri);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block

shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

If I use "shareIntent.setType("*/ *")" Facebook and WhatsApp crashes.

Is there some way to do this? Maybe sent two messages by separate at the same time (WhatsApp).

Thanks in advance.

Answer Source

This is not possible, as WhatsApp does not support messages with both pictures and text in them. A message may consist of a single image, text sequence, audio file, contact or video. You cannot have a combination of any of those.

Rather u can share your text using

    Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
    whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
    try {
    } catch (android.content.ActivityNotFoundException ex) {
        ToastHelper.MakeShortText("Whatsapp have not been installed.");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download