Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Going Two Activities back?

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?

like image 691
iTurki Avatar asked Jul 17 '11 05:07

iTurki


People also ask

How do I go back to activity?

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.

What is activity stack?

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.

What is Flag_activity_new_task?

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.


1 Answers

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.

like image 91
Glendon Trullinger Avatar answered Oct 20 '22 15:10

Glendon Trullinger