android activity生命周期

 

MainActivity:standard

Activity2、Activity3:singleInstance

根据taskId可以判断分处于不同的任务栈。根据对象名称可以判断两次创建MainAcitivity是不同的对象

1、启动app:

MainActivity

onCreate -> onStart -> onResume

2022-02-20 22:03:58.362 12293-12293/com.example.bottomnavigationactivityapp I/TAGBaseActivityy 7770a47: BaseActivity:  //父类输出的结果
2022-02-20 22:03:58.362 12293-12293/com.example.bottomnavigationactivityapp I/TAGMainActivityy:: MainActivity:
2022-02-20 22:03:58.368 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78377 TAGMainActivityy: 7770a47: onCreate:  // 父类输出的结果
2022-02-20 22:03:58.368 12293-12293/com.example.bottomnavigationactivityapp I/TAGMainActivityy:: onCreate:  
2022-02-20 22:03:58.424 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78377 TAGMainActivityy: 7770a47: onStart
2022-02-20 22:03:58.425 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78377 TAGMainActivityy: 7770a47: onResume

 

2、打开下一个activity2

MainActivity->Activity2

MainActivity:onPause

Activity2:onCreate -> onStart -> onResume

MainActivity:onStop

 

2022-02-20 22:05:29.670 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78377	TAGMainActivityy:	7770a47: onPause
2022-02-20 22:05:29.684 12293-12293/com.example.bottomnavigationactivityapp I/TAGBaseActivityy	7186066: BaseActivity: 
2022-02-20 22:05:29.684 12293-12293/com.example.bottomnavigationactivityapp I/TAGActivityy2:: Activity2: 
2022-02-20 22:05:29.691 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78378	TAGActivityy2:	7186066: onCreate: 
2022-02-20 22:05:29.691 12293-12293/com.example.bottomnavigationactivityapp I/TAGActivityy2:: onCreate: 
2022-02-20 22:05:29.739 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78378	TAGActivityy2:	7186066: onStart
2022-02-20 22:05:29.741 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78378	TAGActivityy2:	7186066: onResume
2022-02-20 22:05:30.246 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78377	TAGMainActivityy:	7770a47: onStop:

 

2、打开下一个activity3

Activity2->Activity3

2022-02-20 22:07:11.853 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78378	TAGActivityy2:	7186066: onPause
2022-02-20 22:07:11.870 12293-12293/com.example.bottomnavigationactivityapp I/TAGBaseActivityy	ea663a4: BaseActivity: 
2022-02-20 22:07:11.870 12293-12293/com.example.bottomnavigationactivityapp I/TAGActivityy3:: Activity3: 
2022-02-20 22:07:11.876 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78379	TAGActivityy3:	ea663a4: onCreate: 
2022-02-20 22:07:11.913 12293-12293/com.example.bottomnavigationactivityapp I/TAGActivityy3:: onCreate: 
2022-02-20 22:07:11.916 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78379	TAGActivityy3:	ea663a4: onStart
2022-02-20 22:07:11.918 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78379	TAGActivityy3:	ea663a4: onResume
2022-02-20 22:07:12.430 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78378	TAGActivityy2:	7186066: onStop:

 

3、

Activity3->MainActivity

省略……

4、返回键

从MainActivity->MainActivity

2022-02-20 22:11:42.814 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	7734107: onPause
2022-02-20 22:11:42.830 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	ce249b9: onRestart: 
2022-02-20 22:11:42.834 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	ce249b9: onStart
2022-02-20 22:11:42.835 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	ce249b9: onResume
2022-02-20 22:11:43.214 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	7734107: onStop: 
2022-02-20 22:11:43.217 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	7734107: onDestroy: 

 

5返回键

MainActivity->activity3

2022-02-20 22:12:36.190 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	ce249b9: onPause
2022-02-20 22:12:36.215 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78385	TAGActivityy3:	3cacbb0: onRestart: 
2022-02-20 22:12:36.217 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78385	TAGActivityy3:	3cacbb0: onStart
2022-02-20 22:12:36.220 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78385	TAGActivityy3:	3cacbb0: onResume
2022-02-20 22:12:36.801 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	ce249b9: onStop: 
2022-02-20 22:12:36.811 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78383	TAGMainActivityy:	ce249b9: onDestroy: 

 

6、返回键

activity3->activity2

2022-02-20 22:12:59.720 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78385	TAGActivityy3:	3cacbb0: onPause
2022-02-20 22:12:59.734 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78384	TAGActivityy2:	19fcf63: onRestart: 
2022-02-20 22:12:59.742 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78384	TAGActivityy2:	19fcf63: onStart
2022-02-20 22:12:59.744 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78384	TAGActivityy2:	19fcf63: onResume
2022-02-20 22:13:00.321 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78385	TAGActivityy3:	3cacbb0: onStop: 
2022-02-20 22:13:00.324 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78385	TAGActivityy3:	3cacbb0: onDestroy: 

 

7、返回键

退出了App

2022-02-20 22:13:14.162 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78384	TAGActivityy2:	19fcf63: onPause
2022-02-20 22:13:14.661 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78384	TAGActivityy2:	19fcf63: onStop: 
2022-02-20 22:13:14.674 12293-12293/com.example.bottomnavigationactivityapp I/taskId=78384	TAGActivityy2:	19fcf63: onDestroy: 

 

上一篇:关于linux配置Redis的make命令报错


下一篇:Redis安装教程