Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You say</p> <pre><code>Gmail &gt;&gt; Message &gt;&gt; Open attachment in my application &gt;&gt; ImportActivity &gt;&gt; RootActivity </code></pre> <p>but that may not be right. In this circumstance, gmail will issue an <code>Intent</code> targeted at the <code>ImportActivity</code> in your app. <code>ImportActivity</code> will execute. However, my reading of <a href="https://developer.android.com/guide/components/tasks-and-back-stack.html" rel="noreferrer">https://developer.android.com/guide/components/tasks-and-back-stack.html</a> suggests that <code>ImportActivity</code> will execute as part of the same task as gmail and will be put on top of the back stack for the gmail task, unless you take special steps in the manifest to prevent that or gmail specifically invokes it as a separate task. When <code>ImportActivity</code> finishes, it shouldn't call <code>startActivity(intentForRootActivity)</code> but should just call <code>finish()</code> so that it will be destroyed and the activity from gmail which lies underneath it in the back stack will appear. </p> <p>If <code>ImportActivity</code> did call <code>startActivity(intentForRootActivity)</code> then <code>RootActivity</code> would just go onto the top of the gmail task and appear on the gmail back stack. Touching <code>home</code> and then the launcher icon for gmail would see <code>RootActivity</code> reappear, hiding gmail underneath.</p> <p>I think you need <code>android:launchMode="standard"</code> in the manifest declaration of <code>ImportActivity</code>.</p> <p>The task which represents the older, stand-alone instance of your app will not be modified. If someone touches the launcher icon for your app, the old state of your app will be restored, unaffected by whatever happened in the gmail task.</p> <p>The document <a href="http://developer.android.com/guide/components/processes-and-threads.html" rel="noreferrer">http://developer.android.com/guide/components/processes-and-threads.html</a> is rather vague about how Activities map onto processes here (causing David Wasser to comment on my earlier version of this answer) but it seems that the Activities of gmail will execute in one linux process with one linux user id and the <code>ImportActivity</code> will execute in another linux process with another user id. However, they can all form part of one task with one back stack.</p> <p><code>ImportActivity</code> will execute, as part of the gmail task, with the same effective Linux User ID as it would had it executed as part of your standalone app - and different from the Linux user ID that gmail executes with. This sounds unlikely and complicated but seems to be implied by <a href="https://developer.android.com/guide/components/fundamentals.html" rel="noreferrer">https://developer.android.com/guide/components/fundamentals.html</a>. That makes sense; if <code>ImportActivity</code> needs to get at, say, the user preferences stored for your app, it needs to read the preference file as if it were the user defined for your app, not the user defined for gmail.</p> <p>I haven't tried executing any of this. If I have hold of entirely the wrong end of the stick, I'm sure someone will soon tell us!</p>
 

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