H
H
Hakito2016-01-15 23:33:54
Android
Hakito, 2016-01-15 23:33:54

How to pass image and text to Intent?

I want to add the "Share" function to the application. To do this, I create an intent, specify the desired action:

Intent shareIntent = new Intent();
 shareIntent.setAction(Intent.ACTION_SEND);

I need to send a picture and a caption to it. Please tell me what mime type to use and where to write a picture with text?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Dorofeev, 2016-01-16
@TechCloud

Decision:

Uri imageUri = Uri.parse("android.resource://" + getPackageName()
        + "/drawable/" + "image");
 Intent shareIntent = new Intent();
 shareIntent.setAction(Intent.ACTION_SEND);
 shareIntent.putExtra(Intent.EXTRA_TEXT, "Text");
 shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
 shareIntent.setType("image/jpeg");
 shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
 startActivity(Intent.createChooser(shareIntent, "send"));

C
Copperfield, 2016-01-16
@Copperfield

Send Binary Content

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question