Ian Lake
1 min readApr 22, 2016

--

No, it is Activity A (the one that called startActivityForResult()) that could die while Activity B is the foreground activity.

Let’s assume Activity A and Activity B are in different processes (if they’re the same process, that process will still be the foreground process and the last thing to be killed by the system).

This means that when Activity A calls startActivityForResult() for Activity B, Activity B becomes the foreground activity and the process for Activity A becomes a background process (or a visible process if Activity B is semi-transparent).

Either way, this puts Activity A’s process at a lower priority level than Activity B’s process. So when memory runs low (a more common occurrence on some devices when launching a heavy Activity such as the camera), Activity A’s process might be killed.

Of course, when Activity B is finished, the system knows to recreate Activity A and deliver the result to onActivityResult(), just as if Activity A hadn’t died at all.

The key difference is that any callback class instances, member variables, and even static variables (remember your whole process was killed!) you might have created in Activity A prior to calling startActivityForResult() are destroyed along with Activity A’s process.

--

--