I have an app with 3 activities.
I have the main activity. This calls the second activity, which then calls the third activity. I want return to the main activity without entering the onCreate.
This is the code for the third activity:
startActivity(new Intent(TerceraActiviry.this, Main.class));
in order to get back to previous Activity you have to finish the visible one, use this:
If the activity was started for a result, you should give a result then, like this:
And you should catch the result on the caller Activity using:
Hope it helps, Regards
The launch mode flag you want is clearTop. This will go back to the previous instance of the main activity and clear the second and third activity off the activity stack. For example, to do this from the code:
You startActivityForResult instead of startActivity.
refer the android dev for more info here.
If your
Activity
is still running, this code will bring it to the front without enteringonCreate