Take the 2-minute tour ×

Some days ago I have published my application in Android Marketplace and a question came into my mind during designing and developing application. This question is about limitation or unlimitation of number of activities.

For example, my application includes 37 activities. Is it so much? I want to know for a game such as "Angry Birds" which has more than 200 levels, it has 200 activities?!!

My next question is, assume that I am designing an application which includes 100 activities. User starts application and gos into last activity (such as reading a book). If user wants to close the application what should he do? 100 times press back key on his devise?! If I want to put close button(to help user) in options menu, do I have to repeat it for each activity? because as far as I know each activity has its own menu.

If i put close button in last activity and user clicks on it, program will close. What will happen to other 99 activities? are they still exist in stack? or When I close an application, all activities related to that package will delete from stack.

I have read activities page published by Android but I couldn't find my answers.

Sorry if above questions are stupid questions :) Thank you

share|improve this question
You can close the current activity after the intent to the new activity(By calling finish() in the current activity). In this way the activities that you are not going to use can be closed down or if you want the user to close the application on back button press, then finish every activity after the intent statement –  Ashwin May 17 '12 at 6:39
add comment

4 Answers

up vote 2 down vote accepted

In the case of Anry Bairds, I doubt they have 100s of activities, I think they just have one (or possibly a couple) for levels and another for the welcome screen - different levels are probably loaded depending on some parameter that was passed to the activity.

As for how to handle 100s of loaded activities, first of all, it is very likely that the system will recycle the old ones at the bottom of the stack before you get to the 100th activity. If not, then yes, your user will have to click back through a 100 activities.

If you want to change the behaviour of what the back button, you can override onKeyDown().

Or if you want to change the default behaviour of how activities are launched, then take a look at activities launch mode.

share|improve this answer
add comment

Well, first, regarding angrybirds, I guess it is written nearly entirely in OpenGL ES, so it consists of only a few activities.

And second, if you're really having 200 activities, you should probably think of an activity which can be reused multiple times. e.g. why would you need one activity for every page of a book, if every page should have the same look and functions? Just fire an intent with extra data and it should work. And, to close the app, you can simply press the home button :-)

share|improve this answer
add comment

An application like Angry Birds probably has one activity with an OpenGL ES view, with all of the interfacing done with a RelativeLayout

that being said, you could have an unlimited number of activities, the only concern is how much space your app will take, why any user would want to navigate through such a robust program on their mobile device, and how much RAM you are using and are you managing your activities efficiently

share|improve this answer
add comment

Your Answer


