Skip to content

Instantly share code, notes, and snippets.

@5AbhishekSaxena
Created December 14, 2021 14:32
Show Gist options
  • Save 5AbhishekSaxena/36f723870dc2816361b24f40f71cea78 to your computer and use it in GitHub Desktop.
Save 5AbhishekSaxena/36f723870dc2816361b24f40f71cea78 to your computer and use it in GitHub Desktop.
A series of methods which create objects for different intent types.
fun shareViaSms(context: Context, sms: Sms) {
val chooserTitle = "Sharing with"
val smsSharingIntent = SmsSharingIntent(sms, chooserTitle)
shareIntent(context, smsSharingIntent)
}
fun shareSimpleText(context: Context, text: String) {
val chooserTitle = "Sharing with"
val textSharingIntent = DefaultSharingIntent(context, text, chooserTitle)
shareIntent(context, textSharingIntent)
}
fun openWebPage(context: Context, url: String) {
val chooserTitle = "Open url using"
val webBrowserSharingIntent = WebBrowserSharingIntent(url, chooserTitle)
shareIntent(context, webBrowserSharingIntent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment