3

I'm new to android and java programming. Recently I came across this

Max. number of activities and 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 what i wanted to ask is-

  1. 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?
  2. Now as the above mentioned questions's answer suggests the use of fragments.But when creating fragments, I still have to create individual class for each fragment. Now, is that adding to the no. of activities?
  3. If every fragment class counts as an activity then is it possible to code it all in a single activity?

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

Thank your for your help.

Community
  • 1
  • 1
shadyinside
  • 630
  • 1
  • 8
  • 23

1 Answers1

7

Recently I came across this

That figure is plucked out of the commenter's posterior. 25 is not a magic number.

Moreover, the number of activities does not directly affect performance, any more than a Web site with 1,000 pages is somehow intrinsically slower than a Web site with 100 pages. The number of activities can have impacts on memory usage, particularly depending on how you use those activities (e.g., starting new instances versus navigating back to existing ones).

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

No.

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

The ones where you inherit from Activity.

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

No.

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

Not generally, any more than creating "too much" {{insert programming language here}} files affect the performance of {{insert application environment here}}.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491