Java – No at the maximum. Activity and fragment

No at the maximum. Activity and fragment… here is a solution to the problem.

No at the maximum. Activity and fragment

I am new to Android and Java programming.
Recently I came across this

Max. number of activities
It says this-

We can have any number of activities, but good to limit max to 25 activities (as Google suggests). We can reduce number of activities by using Fragments.

Now the real question I want to ask is-

  1. Does every .java file in the app src count as an activity? If not, then which ones can actually be called activities?
  2. Now fragment is recommended due to the answer to the above question. But when creating fragments, I still have to create separate classes for each fragment. Now, whether to add to no. Activity ?
  3. If each fragment class counts as an activity, can it all be encoded in one activity?

And one more: Does creating too many .java files affect app performance?

Thanks for your help.


Recently I came across this

That figure was taken from the commenter’s hip. 25 is not a magic number.

Also, the number of activities does not directly affect performance, just as a site with 1,000 pages is somehow inherently slower than a site with 100 pages. The number of activities can have an impact on memory usage, especially depending on how you use them (for example, launching a new instance versus navigating back to an existing instance).

Does every .java files in the src of the app count as an activity?


If it doesn’t then which ones can actually be called activities?

Those that you inherit from the activity.

Now, is that adding to the no. of activities?


Does creating too much .java files affect the app performance?

In general, creating “too many” {insert programming language here}} files can affect the performance of {{insert application environment here}}.

Related Problems and Solutions