title: Activity methods:onCreate() and onDestroy()
body: <p>When an activity is created for the first time then system calls the <code>OnContentChanged()</code> method as the first method and last call by system is the <code>OnDetachedFromWindow()</code> method when an activity is killed, but android docs says entire lifetime of an Activity happens between <code>OnCreate()</code> and <code>OnDestroy()</code>. Why? Please help me in understanding difference between these methods.</p>
  
  <p>Code:</p>
  
  <pre><code>import android.app.Activity;
  import android.content.res.Configuration;
  import android.os.Bundle;
  import android.widget.Toast;
  
  public class ActivitylifecycleActivity extends Activity {
      /** Called when the activity is first created. */
  
      @Override
      public void onContentChanged() {
          super.onContentChanged();   
          Toast.makeText(getApplicationContext(),"1. onContentChanged()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          Toast.makeText(getApplicationContext(),"2. onCreate()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onStart() {
          super.onStart();
          Toast.makeText(getApplicationContext(),"3. onStart()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onRestoreInstanceState(Bundle restoreInstanceState) {
          Toast.makeText(getApplicationContext(),"4. onRestoreinstaneState()", Toast.LENGTH_SHORT).show();
          super.onRestoreInstanceState(restoreInstanceState);
      }
  
      @Override
      public void onRestart() {
          super.onRestart();
          Toast.makeText(getApplicationContext(),"5. onRestart()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      protected void onPostCreate(Bundle onpostcrete) {
          super.onPostCreate(onpostcrete);
          Toast.makeText(getApplicationContext(),"6. onPostCreate()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onResume() {
          super.onResume();
          Toast.makeText(getApplicationContext(),"7. onResume()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      protected void onPostResume() {
          super.onPostResume();
          Toast.makeText(getApplicationContext(),"8. onPostResume()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onAttachedToWindow() {
          super.onAttachedToWindow();
          Toast.makeText(getApplicationContext(),"9. onAttachedToWindow()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onWindowFocusChanged(boolean bo) {
          super.onWindowFocusChanged(true);
          Toast.makeText(getApplicationContext(),"10. onWindowFocusChanged()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onUserLeaveHint() {
          super.onUserLeaveHint();
          Toast.makeText(getApplicationContext(),"11. onUserLeaveHint()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onUserInteraction() {
          super.onUserInteraction();
          ii=0;
          Toast.makeText(getApplicationContext(),"12. onUserInteraction()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onSaveInstanceState(Bundle savedInstanceState) {
          super.onSaveInstanceState(savedInstanceState);
          Toast.makeText(getApplicationContext(),"13. onSaveInstanceState()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onPause() {
          super.onPause();
          Toast.makeText(getApplicationContext(),"14. onPause()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onStop() {
          super.onStop();
          Toast.makeText(getApplicationContext(),"15. onStop()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onDestroy() {
          super.onDestroy();
          Toast.makeText(getApplicationContext(),"16. onDestroy()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onDetachedFromWindow() {
          super.onDetachedFromWindow();
          Toast.makeText(getApplicationContext(),"17. onDetachedFromWindow()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
          Toast.makeText(getApplicationContext(),"18. onConfigurationChanged()", Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public boolean onSearchRequested() {
          super.onSearchRequested();
          Toast.makeText(getApplicationContext(),"19. onSearchRequested()", Toast.LENGTH_SHORT).show();
          return false;
      }
  }
  </code></pre>
  
  <p>In this code, <code>onContentChanged()</code> is called  before <code>onCreate()</code> method and <code>onDetachedFromWindow()</code> is called after <code>onDestroy()</code>. Why?</p>