What does "visibility" refer to in the Activity Lifecycle? onPause vs onStop? <p>The Activity Lifecycle is giving me headaches. The documentation at <a href="http://developer.android.com/reference/android/app/Activity.html" rel="nofollow">http://developer.android.com/reference/android/app/Activity.html</a> is so darn ambiguous when it describes the concept of visibility, that I can't figure out when <code>onStop()</code> is called vs <code>onPause()</code>.</p> <p>Compare the following two statements from the documentation:</p> <blockquote> <p><em>(taken from right beneath the lifecycle diagram)</em></p> <p>The <code>onStart()</code> and <code>onStop()</code> methods can be called multiple times, as the activity becomes visible and hidden to the user.</p> </blockquote> <p>vs</p> <blockquote> <p><em>(further down in the blue table with the "killable" columns)</em></p> <p><code>onPause()</code> Called when the system is about to start resuming a previous activity.</p> </blockquote> <p>What I'd understand from the first quote, is that <code>onStop()</code> is called on activity <code>A</code> when <code>A</code> is "hidden". "Hidden" I'd guess is referring to when another activity <code>B</code> has been resumed and is completely covering actvity <code>A</code>. But the second quote then states that <code>onPause()</code> is called when another activity is about to start resuming. Wouldn't that completely hide activity A as well? Both cases seem to imply that that activity <code>A</code> becomes "hidden", no? According to my likely faulty interpretation, <code>onPause()</code> and <code>onStop()</code> are called in identical situations.</p> <p>The documentation also seems to differ between being hidden (<code>onStop()</code> gets called) and being partial visibility (<code>onPause()</code> gets called). But when is an activity still partially visible? Do they mean literally? Or can an activity still be deemed "partially visible" when it has started up a new activity (activity calls startActivityForResult and starts a date picker activity) that covers the entire screen? Surely the activity is not going get onStop invoked? Its supposed to receive a result any moment!</p> <p>So I'm trying to figure out what I'm not getting. I understand that a call to onPause is guaranteed. That would be when activity <code>A</code> loses focus (device enters sleep mode, screenlock, etc), a different activity <code>B</code> takes the foreground (where activity <code>B</code> may or may not have been initiated by activity <code>A</code>). But at which point is the <code>onStop()</code> invoked on activity <code>A</code>?</p> <p>Is it matter of how many activities have been piled ontop of activity A on the activity stack? Are there two different definitions of "visiblity" at play?</p> <p>Sorry about the wall of text, but I'm really frustrated :S</p> <p>So the question stands: Precisely in which situations is an activity deemed "hidden" such that <code>onStop()</code> is called on it?</p> <p><strong>EDIT:</strong></p> <p>I inserted Toast notifications in each onX method, and discovered some additional weirdness:</p> <ol> <li>Pressing the Home button will <em>always</em> call onStop(). But starting up the application won't call <code>onRestart()</code>. Instead it calls <code>onCreate()</code>. This seems strange to me, but ok...</li> <li>When the "USB Mass Storage" activity is started on top of the main activity, <code>onStop()</code> is called. And when exiting the usb storage activity, returning to the main activity, <code>onRestart()</code> is called, instead of <code>onCreate()</code>.</li> <li>When the device goes into Sleep mode and is waken up, the activity only goes through the <code>onPause()</code> and <code>onResume()</code> cycle.</li> </ol> <p>The last point was expected (although I can't get it to fit in the lifecycle diagram). But whats up with 1. and 2. ?</p> <p>In the first point, I was expecting a call to <code>onRestart()</code> when starting the activity again. Why did it deallocate the activity and call <code>onCreate()</code> instead?</p> <p>And take a look at point nr 2: According to the documentation: when "another activity comes in front of the activity", <code>onPaused()</code> should be called. Isn't that what happened when the USB Storage activity came up? It didn't call <code>onPause()</code>, it went through the <code>onStop()</code> - <code>OnRestart()</code> cycle! Obviously, the documentation doesn't consider that a case where "another activity comes in front of the activity". So what really happened?</p>