Note that there are some explanatory texts on larger screens.

plurals
  1. POIntent for switching between Activities kills my second Activity
    primarykey
    data
    text
    <p>here is my problem: I have multiple activities in my application, two of them are a bit "special". Activity A is a home type of activity, used to launch the other activities. It also holds some other info, that can be updated from the background (uses onNewIntent). In the manifest I've declared it as singleTop. It starts other activities for result, so it can't be singleTask or Instance (startActivityForResult doesn't work with them). Activity B is a standalone Activity, that is launched on certain events, also declared as singleTop. It also starts other activities for result and also uses its onNewIntent. I've two separate notifications, that are linked to the corresponding Activity. I'm using for both</p> <pre><code>intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); </code></pre> <p>The normal flow is:</p> <ol> <li>A is running</li> <li>Something happens - B is launched</li> <li>if user presses Home button I have two notifications for A and B</li> </ol> <p>And the problem: if user presses notification for A, A is launched, but B is killed (due to clear_top flag) if after that user presses notification for B new B is launched (activity is dead, <strong>but I need the old instance</strong>)</p> <p>I've read this article - <a href="http://developer.android.com/guide/components/tasks-and-back-stack.html" rel="nofollow">http://developer.android.com/guide/components/tasks-and-back-stack.html</a> To my understanding FLAG_ACTIVITY_NEW_TASK should launch the activities in separate tasks and FLAG_ACTIVITY_CLEAR_TOP should not kill B in this case. </p> <p>A workaround is to rework the logic, make them singleTasks and handle the result from other activities in onNewIntent, but I prefer not to go this way if another solution is possible. I've also tried </p> <pre><code>FLAG_ACTIVITY_REORDER_TO_FRONT | FLAG_ACTIVITY_SINGLE_TOP </code></pre> <p>and</p> <pre><code>FLAG_ACTIVITY_MULTIPLE_TASK | FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_SINGLE_TOP | FLAG_ACTIVITY_CLEAR_TOP </code></pre> <p>to launch B, but neither works.</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.
 

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