Jetpack Compose 中的共享表
Sharesheet in Jetpack Compose
如何在 Jetpack Compose 中使用 Android 的 Sharesheet 共享内容?
在 @Composable
中,您可以 标准 方式使用 Intent
。
类似于:
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")
}
如何在 Jetpack Compose 中使用 Android 的 Sharesheet 共享内容?
在 @Composable
中,您可以 标准 方式使用 Intent
。
类似于:
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")
}