Note that there are some explanatory texts on larger screens.

plurals
  1. POClear activity stack before launching another activity
    primarykey
    data
    text
    <p>Hi there (my first question here ;-)</p> <p>There might be similar questions but none of them seem to answer my question or gives me a real solution...</p> <hr> <p><em>Problem</em><br> <code>A</code> (root) starts <code>B</code>. <code>B</code> can start other activities. <code>A</code> decides to dismiss the stack (network connection loss) and start <code>C</code>. This seems to be a drastic decision but the user would expect that and that really makes sense in this case...</p> <p><em>Question</em><br> How to do that? I would expect using a certain flag or just call something like <code>dismissStack</code>. But I can't find the <em>right</em> solution (see research below).</p> <p><em>Research</em><br> I read a lot of documentation but the available flags don't match my needs (or I didn't understand it right). Other answers out there tell me to remember the started activities (e.g. in an array) and finish them when needed. But this seems dirty to me and somehow I can't accept that to be the right solution. There must be something cleaner I hope?!<br> (Storing the stack seems even wrong to me. Your app can be killed by the system, so your static data, but your history will be loaded again on startup. So you would have to persist your saved stack. This gets even dirtier...)</p> <p><strong>Update</strong><br> My code and what I have tried (abstracted):</p> <pre><code>// in A startActivityForResult(new Intent(this, B.class), REQUEST_B); // network fail in A // setting any flags on C has no influence startActivityForResult(new Intent(this, C.class), REQUEST_C); </code></pre> <p>(<a href="http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP" rel="nofollow">FLAG_ACTIVITY_CLEAR_TOP</a> is no solution, please read the documentation...)</p> <p>I press <kbd>Back</kbd> on <code>C</code> and <code>B</code> still pops up and is so still there...</p> <p>I can remove the activity by calling <code>finishActivity(REQUEST_B)</code>. But when <code>B</code> started another activity <code>D</code> it will still pop up if I hit <kbd>Back</kbd> on <code>C</code> later. <code>B</code> is gone but <code>D</code> is still there...</p> <hr> <p>I'm sure there is something I didn't understand yet or just missed. Can someone give me a hint or approve my research if it has to be really that way...</p>
    singulars
    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.
 

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