@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")
}
TextFieald
中进行处理? - Youn Tivoli fun shareAppPlayStoreUrl(context: Context){
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, "Check out this awesome app\n "+"https://play.google.com/store/apps/details?id="+context.applicationInfo.packageName)
type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, null)
context.startActivity(shareIntent)
}
@Composable
方法中启动一个 activity 吗? - Tuan Chau