Its pretty clear in the documentation that you can send multiple pieces of data with:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
but it seems, from that one line: shareIntent.setType("image/*");
that all pieces have to be the same data type. What If I wanted to send a picture(image/jpeg) and a hashtag that should go along with in the caption (text/plain)?
How would I handle multiple kinds of content in one shareIntent? Is it possible to send 2 shareIntents to the same activity? How would I handle this?
It's not exactly clear from the question whether you want to send multiple images or just a single image, but with an associated text.
In the first case (multiple images):
Use
ACTION_SEND_MULTIPLE
and provide the list of uris asEXTRA_STREAM
, as in:If it's the second case (image plus text):
Use just
ACTION_SEND
and provide bothEXTRA_STREAM
andEXTRA_TEXT
, for example:If, however, you need to share streams of varying MIME types (such as both pictures and other attachments) just use a more generic MIME type, such as
*/*
. For example:From the documentation of
ACTION_SEND_MULTIPLE
(emphasis mine):This works when mixing, say, images and downloaded files.
If your goal is to share one picture with text, this is the code I would suggest: