0

In my game application I have several different activities that all can be accessed by pressing a button from the main menu activity. Now I only finish() the main menu activity when you exit the application.

But I was wondering if I should be finishing the invidual different activities when I return to main menu?

Does it make that much of a difference? Right now since I am not finishing the activity won't it just go back to the existing activity or is it creating a new one every time I go from the menu to the activity?

Thanks.

droider
  • 302
  • 1
  • 3
  • 11

1 Answers1

0

coming back from activity using back key finished that activity and created new one when you call it using intent again.

So if you are coming from all activities using back key to main menu activity so you only need to call finish to exist the app (if main menu activity is the first Activity while opening the app)

Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36
  • Perfect. One more question. You can leave the activities (not the main menu one) by pressing back or pressing an icon on the screen that will take you back to the main menu. If I understand this correctly if I press the icon to go to the main menu and then from there go back to the activity it will be calling onResume, instead of creating a brand new activity? – droider Jun 16 '12 at 21:15
  • It depends on it's launch mode and flag activity it is standard or single top then other instance may created but if it singletask or single instance only one instance will be created, but when you will use startActiity(intent) Oncreate will be called every time – Dheeresh Singh Jun 16 '12 at 21:23
  • and also depends what you doing "pressing an icon on the screen" option in your code.. – Dheeresh Singh Jun 16 '12 at 21:24
  • if you are just calling the Main menu screen on Icaon pressed then please refer link http://stackoverflow.com/questions/4342761/how-do-you-use-intent-flag-activity-clear-top-to-clear-the-activity-stack – Dheeresh Singh Jun 16 '12 at 21:25
  • http://stackoverflow.com/questions/3007998/on-logout-clear-activity-history-stack-preventing-back-button-from-opening-l – Dheeresh Singh Jun 16 '12 at 21:26