Aleksandar Zoric
Aleksandar Zoric

Reputation: 1483

Is having multiple activites when building a Android application normal?

I know this may seem like a really noob question but I just happen to wonder as I was building a little application I decided to work on.

As I continued to work on the application I have realized that I had 4 activities in total, is this normal? Is is too much? Is there ever more?

And I understand a lot of people will say 'It depends on the app' but is there ever a time where certain apps have more than 4 activities?

Is there a downside to having multiple activities? I just started working on Android a few months back so respond as I have no idea about Android, please.

Thank you.

Upvotes: 0

Views: 41

Answers (2)

PeteH
PeteH

Reputation: 1930

Multiple activities are perfectly normal. There is no arbitrary limit. As their name indicates they tend to represent different activities (i.e., screens) within your application.

As you progress with your Android knowledge you should also investigate fragments. Fragments behave like a nested activity. Each fragment can define its own layout and manage its own lifecycle. When a fragment specifies its own layout, it can be configured with other fragments to adapt to a variety of screen sizes (e.g., phone vs. tablet).

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006644

is this normal?

Having more than one activity is perfectly normal.

is there ever a time where certain apps have more than 4 activities?

Sure:

and so on. Personally, I think the 91 for Amazon Kindle is a bit much, and similarly for the 126 used by Firefox 45.0.2, but that's just me.

Is there a downside to having multiple activities?

It is important that you have a clear plan for how the user is going to navigate through the various parts of your app. Lots of activities make some forms of navigation (e.g., nav drawer) a bit more difficult.

If you think about Web apps, having one dominant activity with lots of fragments or other replaceable bits of UI would be akin to the single-page Web app approach. Even with those apps, usually there are other pages involved (settings, help/about, etc.). Having lots of activities is akin to having a Web app with lots of linked pages/forms. Neither is wrong. They each have their pros and their cons.

Upvotes: 3

Related Questions