【问题标题】:Sharesheet in Jetpack ComposeJetpack Compose 中的共享表
【发布时间】:2021-05-27 03:29:40
【问题描述】:

如何在 Jetpack Compose 中使用 Android 的 Sharesheet 共享内容?

【问题讨论】:

  • 你能在 @Composable 方法中启动一个活动吗?

标签: android kotlin android-jetpack android-jetpack-compose


【解决方案1】:

@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")
}

【讨论】:

  • 啊...这应该很明显 ?‍♂️ 我想所有的事情,包括使用撰写导航的导航,都如此不同,我认为有一种新的/不同的方式...谢谢跨度>
猜你喜欢
  • 1970-01-01
  • 2023-01-05
  • 2020-08-09
  • 2022-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-24
  • 2022-11-10
相关资源
最近更新 更多