Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharesheet in Jetpack Compose

How do I share content using Android's Sharesheet in Jetpack Compose?

enter image description here

like image 412
jacoballenwood Avatar asked Dec 22 '25 12:12

jacoballenwood


1 Answers

Inside a @Composable you can use an Intent in a standard way.

Something like:

val sendIntent: Intent = Intent().apply {
    action = Intent.ACTION_SEND
    putExtra(Intent.EXTRA_TEXT, "This is my text to send.")
    type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, null)
val context = LocalContext.current

Button(onClick = {
    context.startActivity(shareIntent)
}){
    Text("Share")
}

enter image description here

like image 111
Gabriele Mariotti Avatar answered Dec 24 '25 01:12

Gabriele Mariotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!