public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); System.out.println("MainActivity:----------------onCreate--"); Button button=(Button) this.findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent intent=new Intent(MainActivity.this,OtherActivity.class); startActivity(intent); } }); } @Override protected void onStart() { super.onStart(); // The activity is about to become visible. System.out.println("MainActivity:----------------onStart--"); } @Override protected void onResume() { super.onResume(); // The activity has become visible (it is now "resumed"). System.out.println("MainActivity:----------------onResume--"); } @Override protected void onPause() { super.onPause(); // Another activity is taking focus (this activity is about to be "paused"). System.out.println("MainActivity:----------------onPause--"); } @Override protected void onStop() { super.onStop(); // The activity is no longer visible (it is now "stopped") System.out.println("MainActivity:----------------onStop--"); } @Override protected void onDestroy() { super.onDestroy(); // The activity is about to be destroyed. System.out.println("MainActivity:----------------onDestroy--"); } }public class OtherActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.other); System.out.println("OtherActivity:----------------onCreate--"); } @Override protected void onStart() { super.onStart(); // The activity is about to become visible. System.out.println("OtherActivity:----------------onStart--"); } @Override protected void onResume() { super.onResume(); // The activity has become visible (it is now "resumed"). System.out.println("OtherActivity:----------------onResume--"); } @Override protected void onPause() { super.onPause(); // Another activity is taking focus (this activity is about to be "paused"). System.out.println("OtherActivity:----------------onPause--"); } @Override protected void onStop() { super.onStop(); // The activity is no longer visible (it is now "stopped") System.out.println("OtherActivity:----------------onStop--"); } @Override protected void onDestroy() { super.onDestroy(); // The activity is about to be destroyed. System.out.println("OtherActivity:----------------onDestroy--"); } }