cherif cherif - 6 months ago 28
Android Question

Android direct shared

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.

Goal which I am trying to achieve

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:

what my app shows

Any idea how to achieve that?

Answer

You should use .createChooserIntent() instead of .getIntent()

Comments