I have this Activities sequence: Avtivity01 => Avtivity02 => Avtivity03
You can go from Avtivity01
to Avtivity02
after you click a button.
You can go from Avtivity02
to Avtivity03
after you click a button.
-
I want to go from Activity03
to Activity01
DIRECTLY after I click a button.
-
NOTE:
I do NOT want to use Intent
, because I want to have Activity01
as if I pressed the back button from Activity02
How to do that, please?
You opened the new activity from another activity with startActivityForResult. In that case you can just call the finishActivity() function from your code and it'll take you back to the previous activity.
A task is a collection of activities that users interact with when trying to do something in your app. These activities are arranged in a stack—the back stack—in the order in which each activity is opened. For example, an email app might have one activity to show a list of new messages.
When using this flag, if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in. See FLAG_ACTIVITY_MULTIPLE_TASK for a flag to disable this behavior.
Why can't you use an Intent
? You can use the FLAG_ACTIVITY_CLEAR_TOP when you click the button. Edit: If you want to preserve the original instance of the Activity
, you can use this flag in conjunction with FLAG_ACTIVITY_SINGLE_TOP.
Do you ever want to be able to press a button from Activity03 to go back to Activity02? If you ALWAYS want it to go back to Activity01, you could alternatively use android:noHistory="true"
on Activity02 in the manifest and just call finish()
on Activity03.
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