我想将用户重定向到另一个打开 Internet url 的 Activity 。点击按钮。
到目前为止,这是我的代码
Button(onClick = {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))
// Here is some code that starts the activity
}) {
Text(text="APPLY HACK")
}
最佳答案
你可以使用类似的东西:
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))
val context = LocalContext.current
Button(onClick = {
startActivity(context, intent, null) }
) {
Text("BUTTON")
}
关于android - 如何在 Compose 函数的按钮单击中启动 Intent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66940091/