The way to return to the% main Activity
by Intent
, is not really typical, regularly the Activity
parent does not reopen with a Intent
, although it can be done by:
intent = new Intent(MyOtraActivity.this , MyMainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
On the other hand, the secondary activities are regularly opened by a Intent
and these are accumulated in the Back Stack.
If you wish to return to a previous Activity, you simply end up where you are by finish();
, which destroys the Current activity.
Currently it is not good practice to stack several Activity in the Back Stack since we could have mainly problems with memory, for this function we created the Fragments which are opened within an Activity without having to store different Activity in the Back Stack, it would be an incorrect design to continue using several Activity and to be stacked one after the other.