title: Android: Under what circumstances would a Dialog appearing cause onPause() to be called?
body: <p>A snippet from the Android <a href="http://developer.android.com/guide/topics/fundamentals/activities.html#Lifecycle" rel="noreferrer">Activities</a> document(scroll down to the "<strong>foreground lifetime</strong>" line) says :</p>
  
  <blockquote>
    <p>An activity can frequently transition in and out of the foreground—for
    example, <code>onPause()</code> is called when the device goes to sleep <strong><em>or when a
    dialog appears</em></strong>.</p>
  </blockquote>
  
  <p>I don't quite understand this. Under what circumstances should this happen? Is <code>onPause()</code> called only if the context of the dialog in question is different from the activity on top of which the dialog is to be displayed?</p>
  
  <h2>EDIT: Adding code sample to illustrate my doubt in detail</h2>
  
  <p>Going by the above-mentioned quote from document, should my activity's <code>onPause()</code> method get called when the <code>AlertDialog</code> (or just the <code>Dialog</code>) in the following code gets displayed? Should I see the "onPause called" log entry when the dialog is displayed?</p>
  
  <p>But I don't see that happen. And it shouldn't either, if I have understood the Android life cycle correctly! So, what's the document pointing at then?</p>
  
  <pre><code>public class LifeCycleTestActivity extends Activity {
  
      private static final String TAG = "LifeCycleTest";
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          Button btn = (Button) findViewById(R.id.button1);
  
          btn.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  Log.d(TAG, "onClick");
  
                  AlertDialog dialog = new AlertDialog.Builder(LifeCycleTestActivity.this).create();
                   dialog.setMessage("You Clicked on the button");
                   dialog.setTitle("Dialog!");
                   dialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
  
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          dialog.dismiss();
                      }
                  });
                   dialog.setCancelable(true);
                   dialog.show();
  
  
                  /*
                  Dialog dialog = new Dialog(LifeCycleTestActivity.this);
                   dialog.setTitle("Dialog!");
                   dialog.setCancelable(true);
                   dialog.show();
                  */
              }
          });        
      }
  
      @Override
      protected void onPause() {
          Log.d(TAG, "onPause() called");
          super.onPause();
  
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          Log.d(TAG, "onResume() called");
      }
  }
  </code></pre>