Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many Activities in Android?

When i started my Android project i had a misunderstanding that every screen that's shown in the application must be a new activity. Now i am finished with the project , i have checked it on my emulator as well as on a couple of android phones. So far i am not witnessing any problems, but recently i read somewhere that too many activities in the application are a pretty bad idea.

Currently my application has around 15-20 activities.Ideally i heard it should be around 5-6. Do i need to re-structure my code or just finishing every activity after it has done it's part is enough?

like image 647
Desert Ice Avatar asked Apr 06 '12 15:04

Desert Ice


People also ask

How many files will be included in a single Android activity?

Yes you can. But you should define one as default by CATEGORY_DEFAULT. Without default main activity if you have two activities, Android Market do not know what activity to start.

How do I stop activity from another activity?

In Activity [A], on button click, I am calling Activity [B] without finishing Activity [A]. Now in Activity [B], there are two buttons, New and Modify. When the user clicks on modify then pop an activity [A] from the stack with all the options ticked..

What does Android activity mean?

An activity represents a single screen with a user interface just like window or frame of Java. Android activity is the subclass of ContextThemeWrapper class. If you have worked with C, C++ or Java programming language then you must have seen that your program starts from main() function.


1 Answers

While creating complex applications you definite need to create many activities. So it depends on your application how many activities you need. No of activities in a project do not affect the performance.

The effect is produced by the number of activities in the stack of your android. So it is better to keep 5-6 activities in the stack(Finish activities if they are not needed any more).

So create as many Activities as your application demands but keep smaller no of Activities open at a time.

like image 147
Muhammad Nabeel Arif Avatar answered Oct 22 '22 17:10

Muhammad Nabeel Arif