Apply The Ambient Pattern To UI | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/17332237-jetpack-compose/lessons/19

Hey so I remark in this Tutorial that each screen has one Activity and in the Jetpack compose book there is only one Activity The Main one, so what is considered the best practice which one should I follow?

Hey there @lanedri6!

Jetpack Compose doesn’t necessarily push you in any direction in terms of using Activities and Fragments, just Compose UI and similar.

That being said, if you want to reduce the number of files as much as you can, and rely entirely on Compose, using a single Activity with interchangeable composables is the way to go.

However, I also think that the approach I used here, with multiple Activities, is still a valid one. Compose in fact is a UI framework, so it’s not a complete replacement for the Android SDK.

That means a Composable element doesn’t replace Activities and Fragments, it’s more of a completement to the existing Android SDK.

So either works, but choose the one that fits your needs and lets you develop your app in the easiest way, but that doesn’t limit the number of features or behavior you can have.

Hope this answers your question!

Thanks!