we start activity and do not calling finish() on existing activity it keeps existing activity in stack and move to new activity if we press back button we return to previous activity.
Its mean all previous activities not beeing called finish() keep remain into the memory(Stack)
Now problem is i do not want to call finish for every activity is there any centralize place where i can define that keep only last 3 activities in stack and remove rest of them ?
In the Android Manifest in the [activity] tag you can specify android:noHistory – Whether or not the activity should be removed from the activity stack and finished (its finish() method called) when the user navigates away from it and it’s no longer visible on screen —”true” if it should be finished, and “false” if not. The default value is “false”.
A value of “true” means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it. This attribute was introduced in API Level 3.