With Jetpack Compose
, is it a viable way to develop an app by having a single Activity
only, and have Compose
manage navigation between @Composables
? When would it be necessary to add more Activities
or Fragments
?
Long version: I did some Android development years ago, where you would work with Activities
and it was necessary to have multiple of them in any non-trivial app as they were the 'primitive' building blocks of every app. Then, Fragments
came along and it was possible to host different ones within a single activity (they supported replacement etc. all with animations) and suddenly it was possible to implement the same app with fewer activities.
Years later, I'm back to Android development, this time with Jetpack Compose
. I have already written an app with a couple of screens, using Jetpack Compose Navigation
(https://developer.android.com/jetpack/compose/navigation), where @Composables
are replaced and I'm very happy with by how much simpler everything has become. It seems that it is now possible to have an app with just a single activity, possibly without fragments either. I think that sometimes different activities might be necessary, e.g. if the application can process various Intents
, but even then Compose Navigation
supports stuff like deep linking etc.