ActivityCycle day6.2

ActivityCycle day6.2

Activity 7 大生命周期


//通过 日志猫 观察 activity 的生命周期
public class MainActivity extends Activity {

 private static final String Tag = "MainActivity";

 private TextView textview;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Log.i(Tag,"MainActivity : onCreate");
 }
 
 @Override
 protected void onStart() {
  super.onStart();
  Log.i(Tag,"MainActivity : onStart");
 }
 @Override
 protected void onResume() {
  super.onResume();
  Log.i(Tag,"MainActivity : onResume");
 }
 @Override
 protected void onPause() {
  super.onPause();
  Log.i(Tag,"MainActivity : onPause");
 }
 @Override
 protected void onStop() {
  super.onStop();
  Log.i(Tag,"MainActivity : onStop");
 }
 @Override
 protected void onRestart() {
  super.onRestart();
  Log.i(Tag,"MainActivity : onRestart");
 }
 @Override
 protected void onDestroy() {
  super.onDestroy();
  Log.i(Tag,"MainActivity : onDestroy");
 }
 
}

---------------------


public class NextActivity extends Activity {
 private static final String Tag = "MainActivity";
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.nextactivity);
  Log.i(Tag,"NextActivity : onCreate");
 }
 }
 @Override
 protected void onStart() {
  super.onStart();
  Log.i(Tag,"NextActivity : onStart");
 }
 @Override
 protected void onResume() {
  super.onResume();
  Log.i(Tag,"NextActivity : onResume");
 }
 @Override
 protected void onPause() {
  super.onPause();
  Log.i(Tag,"NextActivity : onPause");
 }
 @Override
 protected void onStop() {
  super.onStop();
  Log.i(Tag,"NextActivity : onStop");
 }
 @Override
 protected void onRestart() {
  super.onRestart();
  Log.i(Tag,"NextActivity : onRestart");
 }
 @Override
 protected void onDestroy() {
  super.onDestroy();
  Log.i(Tag,"NextActivity : onDestroy");
 }
 
}

 

你可能感兴趣的:(ActivityCycle)