Pha*_*tom 3 android kotlin android-jetpack-compose
我想将用户重定向到另一个打开互联网 URL 的活动。在按钮上单击。
到目前为止,这是我的代码
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")
}
Run Code Online (Sandbox Code Playgroud)
您可以使用以下内容:
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))
val context = LocalContext.current
Button(onClick = {
startActivity(context, intent, null) }
) {
Text("BUTTON")
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
494 次 |
| 最近记录: |