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));
As your activity enters the paused state, the system calls the onPause() method on your Activity , which allows you to stop ongoing actions that should not continue while paused (such as a video) or persist any information that should be permanently saved in case the user continues to leave your app.
An activity provides the window in which the app draws its UI. This window typically fills the screen, but may be smaller than the screen and float on top of other windows. Generally, one activity implements one screen in an app.
onResume() is called whenever you navigate back to the activity from a call or something else. You can override the onResume method similarly as onCreate() and perform the task.
If your Activity
is still running, this code will bring it to the front without entering onCreate
Intent openMainActivity = new Intent(TerceraActiviry.this, Main.class); openMainActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivityIfNeeded(openMainActivity, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With