Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    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.
    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.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COYour statements at the beginning of this answer are wrong. You are confusing 2 completely different concepts: Android **task** is NOT an operating system **process**. The security model for Android uses unique user-IDs for each application and relies on the operating system's security mechanism. This means that your code will **never** run in the same process (memory) space as Gmail code and it will **never** have the same user-ID as Gmail (or any other application). The import activity **may** be in the same task stack as he Gmail application, this depends on how Gmail starts the activity.
      singulars
    2. COYes, I agree with you that a task is not a process, and that user ids are application-specific, and that `import`'s task stack can depend on how `gmail` sends the intent. Can you direct me to the doc that explains how Activities map onto processes? I couldn't find it.
      singulars
    3. COhttp://developer.android.com/guide/components/processes-and-threads.html The first paragraph states that components (Activity, Service, BroadcastReceiver, ContentProvider) of an application all run together in the same process (by default). You can specify in the manifest which components run in which process if you want to. A detailed description of the security model (which also explains a lot about components, processes, etc.) can be found here: http://source.android.com/tech/security/index.html
      singulars
 

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