Last active
December 14, 2021 13:50
-
-
Save 5AbhishekSaxena/46637a75fc744adb2fdaa347b5133591 to your computer and use it in GitHub Desktop.
Method two for sharing intent using sealed classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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