Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does having too much Activities affect my perfomance?

So, I have nearly 20 Activities because I have nearly 20 Layouts in which are important information (concerning the app content). Well, I have to say in these Activities are mostly TextViews.

Is there something like a "Stack" where Activities can be put? If there is a stack, does it affect the perfomance when running the app? How can I see this stack?

Is there a rule of how much Activities an App should have or does it depend on what the purpose of the App is?

It would be nice if you can explain me how the Activities are held or how they are handled when I run my app. Because I do not want that these 20 Activities to affect my performance.

like image 426
Blnpwr Avatar asked Jan 30 '23 02:01

Blnpwr


1 Answers

First question:

Is there something like a "Stack" where Activities can be put? If there is a stack, does it affect the perfomance when running the app? How can I see this stack?

Yes, you can arrange Activities in a task which organizes them in a back stack. Refer to the documentation on how to work with them.

A task is a collection of activities that users interact with when performing a certain job. The activities are arranged in a stack—the back stack)—in the order in which each activity is opened. For example, an email app might have one activity to show a list of new messages. When the user selects a message, a new activity opens to view that message. This new activity is added to the back stack. If the user presses the Back button, that new activity is finished and popped off the stack. The following video provides a good overview of how the back stack works.

Source: https://developer.android.com/guide/components/activities/tasks-and-back-stack.html

Second question:

Is there a rule of how much Activities an App should have or does it depend on what the purpose of the App is?

Yes, the number of Activites your app needs depends on the use case and even your style of structuring your project. You could also use Fragments and replace them in one Activity when needed for instance. There are prons and cons for both ways.

like image 58
Willi Mentzel Avatar answered Feb 03 '23 07:02

Willi Mentzel