2024-05-2903:53:57.40121372-21372 yang I onCreate
2024-05-2903:53:57.40321372-21372 yang I onStart
2024-05-2903:53:57.40521372-21372 yang I onResume
Activity切到后台,锁屏
2024-05-2903:55:14.17421372-21372 yang I onPause
2024-05-2903:55:14.64721372-21372 yang I onStop
2024-05-2903:55:14.64821372-21372 yang I onSaveInstanceState
Activity返回前台
2024-05-2903:55:42.33721372-21372 yang I onRestart
2024-05-2903:55:42.34021372-21372 yang I onStart
2024-05-2903:55:42.34021372-21372 yang I onResume
2024-05-2904:13:49.56216759-16759 yang I onCreate
2024-05-2904:13:49.56516759-16759 yang I onStart
2024-05-2904:13:49.56716759-16759 yang I onResume
2024-05-2904:14:00.00916759-16759 yang I onPause
2024-05-2904:14:00.01416759-16759 yang I onStop
2024-05-2904:14:00.01516759-16759 yang I onSaveInstanceState
2024-05-2904:14:00.01516759-16759 yang I onDestroy
2024-05-2904:14:00.07716759-16759 yang I onCreate
2024-05-2904:14:00.08916759-16759 yang I onStart
2024-05-2904:14:00.09016759-16759 yang I onRestoreInstanceState
2024-05-2904:14:00.09016759-16759 yang I onResume
2024-05-2904:15:54.48417090-17090 yang I onCreate
2024-05-2904:15:54.48617090-17090 yang I onStart
2024-05-2904:15:54.48817090-17090 yang I onResume
2024-05-2904:16:05.74617090-17090 yang I onConfigurationChanged
2024-05-2904:16:12.11217090-17090 yang I onConfigurationChanged
constval TAG ="Yang"class MainActivity :AppCompatActivity(){var mImageView : MyImageView ?=nulloverridefunonCreate(savedInstanceState: Bundle?){super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)
mImageView =findViewById(R.id.real_iv)
mImageView?.setOnClickListener{val intent =Intent(this, MainActivity::class.java)startActivity(intent)}
Log.i("yang","$this onCreate")}overridefunonStart(){super.onStart()
Log.i("yang","$this onStart")}overridefunonResume(){super.onResume()
Log.i("yang","$this onResume")}overridefunonPause(){super.onPause()
Log.i("yang","$this onPause")}overridefunonStop(){super.onStop()
Log.i("yang","$this onStop")}overridefunonDestroy(){super.onDestroy()
Log.i("yang","$this onDestroy")}overridefunonRestart(){super.onRestart()
Log.i("yang","$this onRestart")}overridefunonSaveInstanceState(outState: Bundle){super.onSaveInstanceState(outState)
Log.i("yang","$this onSaveInstanceState")}overridefunonRestoreInstanceState(savedInstanceState: Bundle){super.onRestoreInstanceState(savedInstanceState)
Log.i("yang","$this onRestoreInstanceState")}overridefunonConfigurationChanged(newConfig: Configuration){super.onConfigurationChanged(newConfig)
Log.i("yang","$this onConfigurationChanged")}overridefunonNewIntent(intent: Intent?){super.onNewIntent(intent)
Log.i("yang","$this onNewIntent")}}// log result2024-05-2905:01:46.73726443-26443 yang I com.yang.app.MainActivity@54d9d4e onCreate
2024-05-2905:01:46.73926443-26443 yang I com.yang.app.MainActivity@54d9d4e onStart
2024-05-2905:01:46.74226443-26443 yang I com.yang.app.MainActivity@54d9d4e onResume
2024-05-2905:01:49.57326443-26443 yang I com.yang.app.MainActivity@54d9d4e onPause
2024-05-2905:01:49.60926443-26443 yang I com.yang.app.MainActivity@4c77c18 onCreate
2024-05-2905:01:49.62126443-26443 yang I com.yang.app.MainActivity@4c77c18 onStart
2024-05-2905:01:49.62226443-26443 yang I com.yang.app.MainActivity@4c77c18 onResume
2024-05-2905:01:49.98326443-26443 yang I com.yang.app.MainActivity@54d9d4e onStop
2024-05-2905:01:49.98426443-26443 yang I com.yang.app.MainActivity@54d9d4e onSaveInstanceState
2024-05-2906:58:47.1242160-2160 yang I com.yang.app.MainActivity@54d9d4e onCreate
2024-05-2906:58:47.1262160-2160 yang I com.yang.app.MainActivity@54d9d4e onStart
2024-05-2906:58:47.1282160-2160 yang I com.yang.app.MainActivity@54d9d4e onResume
2024-05-2906:58:49.4442160-2160 yang I com.yang.app.MainActivity@54d9d4e onPause
2024-05-2906:58:49.4442160-2160 yang I com.yang.app.MainActivity@54d9d4e onNewIntent
2024-05-2906:58:49.4452160-2160 yang I com.yang.app.MainActivity@54d9d4e onResume
2024-05-2907:54:20.5687933-7933 yang I com.yang.app.MainActivity@4db5049 onCreate
2024-05-2907:54:20.5767933-7933 yang I com.yang.app.MainActivity@4db5049 onStart
2024-05-2907:54:20.5797933-7933 yang I com.yang.app.MainActivity@4db5049 onResume
2024-05-2907:54:23.0277933-7933 yang I com.yang.app.MainActivity@4db5049 onPause
2024-05-2907:54:23.0547933-7933 yang I com.yang.SecondActivity@7657d8c onCreate
2024-05-2907:54:23.0657933-7933 yang I com.yang.SecondActivity@7657d8c onStart
2024-05-2907:54:23.0667933-7933 yang I com.yang.SecondActivity@7657d8c onResume
2024-05-2907:54:23.4217933-7933 yang I com.yang.app.MainActivity@4db5049 onStop
2024-05-2907:54:23.4227933-7933 yang I com.yang.app.MainActivity@4db5049 onSaveInstanceState
2024-05-2907:54:25.3317933-7933 yang I com.yang.SecondActivity@7657d8c onPause
2024-05-2907:54:25.3357933-7933 yang I com.yang.app.MainActivity@4db5049 onRestart
2024-05-2907:54:25.3387933-7933 yang I com.yang.app.MainActivity@4db5049 onStart
2024-05-2907:54:25.3387933-7933 yang I com.yang.app.MainActivity@4db5049 onNewIntent
2024-05-2907:54:25.3387933-7933 yang I com.yang.app.MainActivity@4db5049 onResume
2024-05-2907:54:25.6837933-7933 yang I com.yang.SecondActivity@7657d8c onStop
2024-05-2907:54:25.6847933-7933 yang I com.yang.SecondActivity@7657d8c onDestroy
val activityManager =getSystemService(Context.ACTIVITY_SERVICE)as ActivityManager
val numActivities = activityManager.appTasks[0].taskInfo.numActivities
Log.i("yang","当前{$this}栈启动Activity数量 = $numActivities")// log result2024-05-2908:14:09.13711888-11888 yang I 当前{com.yang.app.MainActivity@8ae877c}栈启动Activity数量 =12024-05-2908:14:09.13711888-11888 yang I com.yang.app.MainActivity@8ae877c onCreate
2024-05-2908:14:09.14711888-11888 yang I com.yang.app.MainActivity@8ae877c onStart
2024-05-2908:14:09.14911888-11888 yang I com.yang.app.MainActivity@8ae877c onResume
2024-05-2908:14:11.87211888-11888 yang I com.yang.app.MainActivity@8ae877c onPause
2024-05-2908:14:11.90211888-11888 yang I 当前{com.yang.SecondActivity@754bbdb}栈启动Activity数量 =12024-05-2908:14:11.90311888-11888 yang I com.yang.SecondActivity@754bbdb onCreate
2024-05-2908:14:11.91511888-11888 yang I com.yang.SecondActivity@754bbdb onStart
2024-05-2908:14:11.91611888-11888 yang I com.yang.SecondActivity@754bbdb onResume
2024-05-2908:14:12.28611888-11888 yang I com.yang.app.MainActivity@8ae877c onStop
2024-05-2908:14:12.28611888-11888 yang I com.yang.app.MainActivity@8ae877c onSaveInstanceState