0

I am converting my Android mobile app to use Jetpack Compose. At the moment I am starting the activity as an Intent and it works, but I lost the navigation if I do this way:

Button(onClick = {
            val destination = ActivityNavigator(context).createDestination().setIntent(Intent(context, ExternalClass::class.java))
            ActivityNavigator(context).navigate(destination, null, null, null)
        }, colors = ButtonDefaults.textButtonColors(
            backgroundColor = colorResource(R.color.colorAccent)
        )) {
            Text("Go To Activity")
        }

What is my alternative to render this ExternalClass (java) into Jetpack Compose?

1 Answers1

0

Compose doesn't use Activities for navigation, that's why when you're starting a new activity it dismiss whole compose hierarchy

You can wrap your java class using AndroidView and place it into compose navigation destination

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220