sunflower icon indicating copy to clipboard operation
sunflower copied to clipboard

Why having multiple activities?

Open gderaco opened this issue 8 years ago • 4 comments

According to this article, Google suggested using only one Activity:

Today we are introducing the Navigation component as a framework for structuring your in-app UI, with a focus on making a single-Activity app the preferred architecture. With out of the box support for Fragments, you get all of the Architecture Components benefits such as Lifecycle and ViewModel while allowing Navigation to handle the complexity of FragmentTransactions for you.

So my question is, why didn't you follow the advice yourself gave?

gderaco avatar May 29 '18 13:05 gderaco

It does look a bit counter-intuitive that the "master-detail" view is split into 2 activities whereas the less related views are 2 fragments of the same view...

ShiroYacha avatar May 31 '18 10:05 ShiroYacha

why not :)

XinyueZ avatar Jun 02 '18 19:06 XinyueZ

That's correct - a single-Activity app is preferred. We'll be consolidating down to one activity.

tiembo avatar Jun 04 '18 22:06 tiembo

@tiembo @gderaco Navigation within "single-activity" is really a good way to control application route and move direction, do it also, however, my point of view is that activity should capsulate "business" group. A typical example is that user-shop-buying.

I will user-profile with edit, list, view in one activity. For shop, list, detail and gallery of item if needed in one activity. Buying process in one activity.

Flexible with multi-single-activity is my variant of jetpack. This is my opinion

XinyueZ avatar Jun 05 '18 20:06 XinyueZ