Android Share Text or Url Intent

Jun 17, 2018
val url = "https://www.travelopy.com"ShareCompat.IntentBuilder        .from(activity)        .setType("text/plain")        .setChooserTitle("Share URL")        .setText(url)        .startChooser()

NOTE: Will always show chooser dialog even default app is selected.

or

val shareIntent = ShareCompat.IntentBuilder        .from(activity)        .setType("text/plain")        .setChooserTitle("Share URL")        .setText(url)        .intentif (shareIntent.resolveActivity(activity.packageManager) != null) {    activity.startActivity(shareIntent)}

NOTE: Will not show chooser dialog if default app is selected.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.