I am trying to share a link from my app with direct share. The share dialog must be like the image below with the most used contacts from messaging apps, like WhatsApp contacts.
This is the Intent
structure which I am using for share the link:
Intent shareIntent = ShareCompat.IntentBuilder
.from(getActivity())
.setType("text/plain")
.setText(sTitle+ "\n" + urlPost)
.getIntent();
if (shareIntent.resolveActivity(
getActivity().getPackageManager()) != null)
startActivity(shareIntent);
And this is what my app shows:
Any idea how to achieve that?
Direct Share is a feature that allows apps to show app-specific options directly in the system Intent chooser dialog. Users can then jump directly into your app when sharing content from another app.
Once disabled, you will no longer see suggestions to share to individual contacts in apps, and your share menu will be restored to only show app and app actions (with no pesky re-flowing, either).
You should use .createChooserIntent()
instead of .getIntent()
Like this code below, you can use Intent.createChooser
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file://" + filePath);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
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