android – Problems sharing combined text and image with SHARE INTENT on Twitter-ThrowExceptions

Exception or error:

I want to give the user the possibility to share a Image and a Text with Twitter and Facebook.

Actually my code can launch Android’s share intent and if the user selects Facebook, all works fine, the Image is attached and the text is shown on the body of the new status.

But something is wrong with Twitter, if i only put a Image all works fine, the image is detected by twitter and automatically uploaded to twipic, then twitter posts the link of the image on the tweet. But if i put a image and a text, then, twitter doesn’t detect the image and it only puts the text on the tweet, the image is ignored. What is wrong?

this is my code:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file:///sdcard/image.jpg");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
How to solve:

Specify MIME type also for the text. "text/plain" is the type of text data MIME. Try using "*/*" as MIME, so you can send any generic data type.

Also try changing ACTION_SEND to ACTION_SEND_MULTIPLE which specialized for delivering multiple data.

More info about ACTION_SEND_MULTPLE and handling MIME types:


You can still try with ACTION_SEND, without using the ACTION_SEND_MULTIPLE.

ACTION_SEND_MULTIPLE resulted in a force close, when I tried to create new intents for sharing to Gmail, G+, etc.

This worked perfect for me:

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    Uri uri = Uri.parse("file:///sdcard/image.jpg");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    return shareIntent; 

Leave a Reply

Your email address will not be published. Required fields are marked *