打開MainActivity在其中點擊按鈕瞳抓,進(jìn)入BAactivity寝姿,然后再退出疫赎。代碼如下
packagecom.example.liuping.myapplication;
importandroid.content.Intent;
importandroid.support.v7.app.AppCompatActivity;
importandroid.os.Bundle;
importandroid.util.Log;
importandroid.view.View;
public classMainActivityextendsAppCompatActivity {
private static finalStringTAG= MainActivity.class.getSimpleName();
@Override
protected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.e(TAG,"onCreate---"+TAG);
}
@Override
protected voidonStart() {
super.onStart();
Log.e(TAG,"onStart---"+TAG);
}
@Override
protected voidonResume() {
super.onResume();
Log.e(TAG,"onResume---"+TAG);
}
@Override
protected voidonRestart() {
super.onRestart();
Log.e(TAG,"onRestart---"+TAG);
}
@Override
protected voidonRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Log.e(TAG,"onRestoreInstanceState---"+TAG);
}
@Override
protected voidonPause() {
super.onPause();
Log.e(TAG,"onPause---"+TAG);
}
@Override
protected voidonStop() {
super.onStop();
Log.e(TAG,"onStop---"+TAG);
}
@Override
protected voidonDestroy() {
super.onDestroy();
Log.e(TAG,"onDestroy---"+TAG);
}
public voidgoB(View view) {
Intent intent=newIntent(this,BActivity.class);
startActivity(intent);
}
}
結(jié)果如下:
12-13 06:16:06.996 27955-27962/? E/zygote: Failed sending reply to debugger: Broken pipe
12-13 06:16:07.964 27955-27955/? E/MainActivity: onCreate---MainActivity
12-13 06:16:07.967 27955-27955/? E/MainActivity: onStart---MainActivity
12-13 06:16:07.970 27955-27955/? E/MainActivity: onResume---MainActivity
12-13 06:16:08.106 27955-27995/com.example.liuping.myapplication E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
12-13 06:16:08.106 27955-27995/com.example.liuping.myapplication E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
12-13 06:16:08.108 27955-27995/com.example.liuping.myapplication E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
12-13 06:16:08.109 27955-27995/com.example.liuping.myapplication E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
12-13 06:16:21.245 27955-27955/com.example.liuping.myapplication E/MainActivity: onPause---MainActivity
12-13 06:16:21.283 27955-27955/com.example.liuping.myapplication E/BActivity: onCreate---BActivity
12-13 06:16:21.284 27955-27955/com.example.liuping.myapplication E/BActivity: onStart---BActivity
12-13 06:16:21.287 27955-27955/com.example.liuping.myapplication E/BActivity: onResume---BActivity
12-13 06:16:21.815 27955-27955/com.example.liuping.myapplication E/MainActivity: onStop---MainActivity
12-13 06:17:13.864 27955-27955/com.example.liuping.myapplication E/BActivity: onPause---BActivity
12-13 06:17:13.879 27955-27955/com.example.liuping.myapplication E/MainActivity: onRestart---MainActivity
12-13 06:17:13.879 27955-27955/com.example.liuping.myapplication E/MainActivity: onStart---MainActivity
12-13 06:17:13.880 27955-27955/com.example.liuping.myapplication E/MainActivity: onResume---MainActivity
12-13 06:17:14.258 27955-27955/com.example.liuping.myapplication E/BActivity: onStop---BActivity
12-13 06:17:14.259 27955-27955/com.example.liuping.myapplication E/BActivity: onDestroy---BActivity
a:oncreate? ?onstart onresume??
點擊跳轉(zhuǎn):a:onpause?
b:oncreate on start onresume
a :onstop? a壓入activity棧
點擊返回:b:onpause
a:onrestart 彈出棧? onstart onresume
b:onstop ondestory 退出任務(wù)棧