I'm using the following method to share an image with any app the user picks.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
File imageFileToShare = new File(imagePath);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(imageFileToShare));
if (!TextUtils.isEmpty(text)) {
shareIntent.putExtra(Intent.EXTRA_TEXT, text);
}
context.startActivity(Intent.createChooser(shareIntent, "Share with").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
This works fine, but now I'm trying to get the name of the app picked by the user for sharing. Is there a (standard) way to do this?
Thanks for the attention. Jose
This is not supported prior to Android 6.0, when using the Android chooser. On Android 6.0+, you can use EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
to provide an IntentSender
that will be notified when the user makes a choice and what that choice is.
You are welcome to use PackageManager
and queryIntentActivities()
to find out what activities support your shareIntent
and create your own UI for the user to choose from. Then, since it is your own UI, you will find out what the user chose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With