Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In short: no, your code snippet will push a new instance of <code>Login</code> onto the activity stack. Please read more about the behaviour of the activity stack in the <a href="http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html" rel="nofollow noreferrer">Tasks and Back Stack</a> article on developer.android.com.</p> <blockquote> <p>Because the activities in the back stack are never rearranged, if your application allows users to start a particular activity from more than one activity, a new instance of that activity is created and popped onto the stack (rather than bringing any previous instance of the activity to the top). As such, one activity in your application might be instantiated multiple times (even from different tasks), as shown in figure 3.</p> </blockquote> <p><strong>Figure 3:</strong></p> <p><img src="https://i.stack.imgur.com/kYIxI.png" alt="Figure 3"></p> <p>A possible solution is also give there, under <a href="http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html#ManagingTasks" rel="nofollow noreferrer">Managing Tasks</a>. You can add a <a href="http://developer.android.com/reference/android/content/Intent.html#setFlags%28int%29" rel="nofollow noreferrer">flag</a> to the Intent specifying what Android should do in case an activity already exists on the stack. I would say <code>FLAG_ACTIVITY_REORDER_TO_FRONT</code> or <code>FLAG_ACTIVITY_CLEAR_TOP</code> may be what you're looking for, but definitely have a browse through the other options as there might be one that better suits your needs.</p> <p>Alternatively, if the flow in your app allows it, you could finish an activity if the user navigates aways from it. For instance, in your example: if the user navigates away from activity #2 to activity #3, finish #2. Pressing the back button from #3 will then result in activity #1 being presented, since that will then be the one on the top of the stack.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload