Skip to content

Instantly share code, notes, and snippets.

@5AbhishekSaxena
Last active December 14, 2021 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 5AbhishekSaxena/46637a75fc744adb2fdaa347b5133591 to your computer and use it in GitHub Desktop.
Save 5AbhishekSaxena/46637a75fc744adb2fdaa347b5133591 to your computer and use it in GitHub Desktop.
Method two for sharing intent using sealed classes
val sharingIntentFactory = SharingIntentFactory()
fun shareViaSms(context: Context, sms: Sms) {
val sharingType = SharingType.SmsType(sms)
val intent = sharingIntentFactory.prepareIntent(context, sharingType)
startActivity(context, intent, "Sharing with")
}
fun shareSimpleText(context: Context, text: String) {
val sharingType = SharingType.Default(text)
val intent = sharingIntentFactory.prepareIntent(context, sharingType)
startActivity(context, intent, "Sharing with")
}
fun openWebPage(context: Context, url: String) {
val sharingType = SharingType.WebBrowserType(url)
val intent = sharingIntentFactory.prepareIntent(context, sharingType)
startActivity(context, intent, "Open url using")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment