Answer the question
In order to leave comments, you need to log in
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);
Answer the question
In order to leave comments, you need to log in
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"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question