How to navigate from a composable to an activity or a fragment in Jetpack Compose?

In newer version of compose use LocalContext.
In older versions (1.0.0-alpha08 and before) use AmbientContext:

@Composable
fun MainScreen() {
    val context = LocalContext.current

    Button(onClick = {
        context.startActivity(Intent(context, ListActivity::class.java))
    }) {
        Text(text = "Show List")
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)