Issue
I want to redirect the user to another activity that opens a internet url. On button click.
Here is my code so far
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")
}
Solution
You can use something like:
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))
val context = LocalContext.current
Button(onClick = {
startActivity(context, intent, null) }
) {
Text("BUTTON")
}
Answered By - Gabriele Mariotti
Answer Checked By - Mildred Charles (JavaFixing Admin)