android activity与fragment生命周期
背景:主活动MainActivity继承自BaseActivity;MainActivity包含HomeFragment;Fragment继承自BaseFragment。
这三个Tab切换Fragment是通过AS自动生成的。所以后文在切换Fragment的生命周期变换,可能是被设置好的。
一、启动App:
1.MainActivity的:构造方法
2.MainActivity的:onCreate
3.HomeFragment的:构造方法
4.HomeFragment的:onAttach->onCreate->onCreateView->onActivityCreated->(onViewStateRestored)->onStart
5.MainActivity的:onStart->onResume
6.HomeFragment的:onResume
2022-02-20 20:32:42.115 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseActivityy ad7cf20: BaseActivity: 2022-02-20 20:32:42.115 31706-31706/com.example.bottomnavigationactivityapp I/TAGMainActivityy:: MainActivity: 2022-02-20 20:32:42.139 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onCreate: 2022-02-20 20:32:42.139 31706-31706/com.example.bottomnavigationactivityapp I/TAGMainActivityy:: onCreate: 2022-02-20 20:32:42.252 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: HomeFragment{12684e6} (d70efaca-08be-43c5-b08f-46dc880de25a)} 2022-02-20 20:32:42.252 31706-31706/com.example.bottomnavigationactivityapp I/TAGHomeFragment: HomeFragment: 2022-02-20 20:32:42.266 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onAttach: 2022-02-20 20:32:42.267 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onCreate: 2022-02-20 20:32:42.267 31706-31706/com.example.bottomnavigationactivityapp I/TAGHomeFragment: onCreateView: 2022-02-20 20:32:42.270 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onActivityCreated: 2022-02-20 20:32:42.270 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onViewStateRestored: 2022-02-20 20:32:42.273 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onStart: 2022-02-20 20:32:42.273 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onStart 2022-02-20 20:32:42.277 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onResume 2022-02-20 20:32:42.278 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onResume:
二、跳转到其它App,或者通过Home按键返回主界面:
1.HomeFragment的:onPause
2.MainActivity的:onPause
3.HomeFragment:的onStop
4.MainActivity的:onStop
5.HomeFragment的:onSaveInstanceState
2022-02-20 20:44:42.264 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onPause: 2022-02-20 20:44:42.265 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onPause 2022-02-20 20:44:43.070 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onStop: 2022-02-20 20:44:43.071 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onStop: 2022-02-20 20:44:43.080 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onSaveInstanceState:
fragment生命周期先开始:与activity交替执行。(注意:这儿没有执行HomeFragment的onDestroyView方法)
三、重新点开APP(此时是热启动)
1.MainActivity的:onRestart
2.HomeFragment的:onStart
3.MainActivity的:onStart
4.MainActivity的:onResume
5.HomeFragment的:onResume
2022-02-20 20:52:17.895 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onRestart: 2022-02-20 20:52:17.899 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onStart: 2022-02-20 20:52:17.900 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onStart 2022-02-20 20:52:17.903 31706-31706/com.example.bottomnavigationactivityapp I/taskId=78360 TAGMainActivityy: ad7cf20: onResume 2022-02-20 20:52:17.904 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onResume:
通过一、三可以总结出来:2-3-4-5顺序固定:
2.HomeFragment的:onStart 3.MainActivity的:onStart 4.MainActivity的:onResume 5.HomeFragment的:onResume
四、切换到第二个DashFragment
1.DashFragment的:构造方法 fd4b1fa
2.DashFragment的:onAttach->onCreate->onCreateView->onActivityCreated->(onViewStateRestored)->onStart->onResume
3.HomeFragment的:onPause->onStop->onDestroyView
注意:这儿的 DashFragment没有执行onCreateView(可能是因为替换fragment不需要执行这一步生命周期方法),这儿的HomeFragment-12684e6执行了onDestroyView。
2022-02-20 21:03:30.367 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: DashboardFragment{fd4b1fa} (a34a76e1-d108-44c3-8fbd-baff3bcf0f4d)} 2022-02-20 21:03:30.367 31706-31706/com.example.bottomnavigationactivityapp I/TAGDashboardFragment: DashboardFragment: 2022-02-20 21:03:30.386 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onAttach: 2022-02-20 21:03:30.387 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onCreate: 2022-02-20 21:03:30.396 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onActivityCreated: 2022-02-20 21:03:30.397 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onViewStateRestored: 2022-02-20 21:03:30.398 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onStart: 2022-02-20 21:03:30.399 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onResume: 2022-02-20 21:03:30.405 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onPause: 2022-02-20 21:03:30.406 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onStop: 2022-02-20 21:03:30.557 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onDestroyView:
五、再次点击第一个fragment
创建新的HomeFragmend-6d5e5
HomeFragmend-6d5e5重新执行了onCreateView
上一个HomeFragment-12684e6销毁了onDestroy->onDetach
DashFragment最终被detach了。【DashFragment-fd4b1fa销毁了onPause->onStop->onDestroyView->onDestroy->onDetach(这儿DashFragment-fd4b1fa为什么会被销毁)】
2022-02-20 21:08:40.731 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: HomeFragment{d6d35e5} (0b79f600-95be-4cd2-ba38-228e528c3082)} 2022-02-20 21:08:40.731 31706-31706/com.example.bottomnavigationactivityapp I/TAGHomeFragment: HomeFragment: 2022-02-20 21:08:40.747 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onAttach: // 2022-02-20 21:08:40.749 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onCreate: 2022-02-20 21:08:40.749 31706-31706/com.example.bottomnavigationactivityapp I/TAGHomeFragment: onCreateView: // 重新执行了 2022-02-20 21:08:40.755 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onActivityCreated: 2022-02-20 21:08:40.756 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onViewStateRestored: 2022-02-20 21:08:40.757 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onStart: 2022-02-20 21:08:40.759 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onResume: 2022-02-20 21:08:40.762 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onDestroy: // 2022-02-20 21:08:40.763 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 12684e6: onDetach: 2022-02-20 21:08:40.764 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onPause: 2022-02-20 21:08:40.765 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onStop: 2022-02-20 21:08:40.921 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onDestroyView: 2022-02-20 21:08:40.922 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onDestroy: 2022-02-20 21:08:40.923 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment fd4b1fa: onDetach:
六、再次点击DashFragment
结果与四相同
创建了新的DashFragment-d284472
HomeFragment-6d5e5:onPause-onStop->onDestroyView
2022-02-20 21:10:45.864 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: DashboardFragment{d284472} (486b855b-2996-49ce-9754-93a7106e6333)} 2022-02-20 21:10:45.865 31706-31706/com.example.bottomnavigationactivityapp I/TAGDashboardFragment: DashboardFragment: 2022-02-20 21:10:45.873 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onAttach: 2022-02-20 21:10:45.875 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onCreate: 2022-02-20 21:10:45.880 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onActivityCreated: 2022-02-20 21:10:45.880 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onViewStateRestored: 2022-02-20 21:10:45.881 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onStart: 2022-02-20 21:10:45.882 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onResume: 2022-02-20 21:10:45.886 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onPause: 2022-02-20 21:10:45.887 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onStop: 2022-02-20 21:10:46.030 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onDestroyView:
七、点击NotificationFragment
DashFragment最终被detach了。与五一样
2022-02-20 21:10:56.703 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: NotificationsFragment{1f5dff7} (d38f7d51-cc89-4464-9702-b56ce08787ee)} 2022-02-20 21:10:56.703 31706-31706/com.example.bottomnavigationactivityapp I/TAGNotificationsFragment: NotificationsFragment: 2022-02-20 21:10:56.710 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onAttach: 2022-02-20 21:10:56.710 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onCreate: 2022-02-20 21:10:56.718 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onActivityCreated: 2022-02-20 21:10:56.719 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onViewStateRestored: 2022-02-20 21:10:56.720 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onStart: 2022-02-20 21:10:56.721 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onResume: 2022-02-20 21:10:56.725 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onPause: 2022-02-20 21:10:56.725 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onStop: 2022-02-20 21:10:56.867 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onDestroyView: 2022-02-20 21:10:56.868 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onDestroy: 2022-02-20 21:10:56.869 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment d284472: onDetach:
八、点击DashFragment
NotificationFragment最终被detach了。与五、七一样。
2022-02-20 21:11:14.032 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: DashboardFragment{392963a} (f917360c-ef37-476c-ac2e-554abd048617)} 2022-02-20 21:11:14.032 31706-31706/com.example.bottomnavigationactivityapp I/TAGDashboardFragment: DashboardFragment: 2022-02-20 21:11:14.041 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment 392963a: onAttach: 2022-02-20 21:11:14.045 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment 392963a: onCreate: 2022-02-20 21:11:14.049 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment 392963a: onActivityCreated: 2022-02-20 21:11:14.050 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment 392963a: onViewStateRestored: 2022-02-20 21:11:14.050 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment 392963a: onStart: 2022-02-20 21:11:14.052 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGDashboardFragment 392963a: onResume: 2022-02-20 21:11:14.055 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onPause: 2022-02-20 21:11:14.056 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onStop: 2022-02-20 21:11:14.198 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onDestroyView: 2022-02-20 21:11:14.199 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onDestroy: 2022-02-20 21:11:14.199 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 1f5dff7: onDetach:
由以上可知:
HomeFragment在切换Fragment的过程中,只有再次切换到自己去创建新的homeFragment对象的时候,旧的fragment才会被detach销毁。
DashNotification与NotificationFragment,在切换Fragment过程中,只要切换到其它Fragment对象,就会被销毁onPause-onDetach。
九、再次点击HomeFragment
2022-02-20 21:11:24.721 31706-31706/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: HomeFragment{5683413} (a12b532f-cdd7-4075-ad3e-53dbbe0dca27)} 2022-02-20 21:11:24.721 31706-31706/com.example.bottomnavigationactivityapp I/TAGHomeFragment: HomeFragment: 2022-02-20 21:11:24.727 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 5683413: onAttach: 2022-02-20 21:11:24.728 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 5683413: onCreate: 2022-02-20 21:11:24.729 31706-31706/com.example.bottomnavigationactivityapp I/TAGHomeFragment: onCreateView: 2022-02-20 21:11:24.734 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 5683413: onActivityCreated: 2022-02-20 21:11:24.735 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 5683413: onViewStateRestored: 2022-02-20 21:11:24.735 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 5683413: onStart: 2022-02-20 21:11:24.736 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment 5683413: onResume: 2022-02-20 21:11:24.738 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onDestroy: 2022-02-20 21:11:24.738 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGHomeFragment d6d35e5: onDetach: 2022-02-20 21:11:24.739 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 5b91eec: onPause: 2022-02-20 21:11:24.742 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 5b91eec: onStop: 2022-02-20 21:11:24.885 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 5b91eec: onDestroyView: 2022-02-20 21:11:24.886 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 5b91eec: onDestroy: 2022-02-20 21:11:24.886 31706-31706/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78360 TAGNotificationsFragment 5b91eec: onDetach:
下面的对象id对不上,是因为重新启动了App
十、(当前处于进入App第一个界面,创建了MainActivity和HomeFragment)返回键退出APP
HomeFragment:onPause
MainActivity:onPause
HomeFragment:onStop
MainActivity:onStop
HomeFragment:onDestroyView-> onDestroy->onDetach
MainActivity:onDestroy
2022-02-20 21:46:33.518 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78371 TAGHomeFragment f2cbb7e: onPause: 2022-02-20 21:46:33.519 10433-10433/com.example.bottomnavigationactivityapp I/taskId=78371 TAGMainActivityy: 2267e09: onPause 2022-02-20 21:46:34.030 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78371 TAGHomeFragment f2cbb7e: onStop: 2022-02-20 21:46:34.032 10433-10433/com.example.bottomnavigationactivityapp I/taskId=78371 TAGMainActivityy: 2267e09: onStop: 2022-02-20 21:46:34.037 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78371 TAGHomeFragment f2cbb7e: onDestroyView: 2022-02-20 21:46:34.039 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78371 TAGHomeFragment f2cbb7e: onDestroy: 2022-02-20 21:46:34.040 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78371 TAGHomeFragment f2cbb7e: onDetach: 2022-02-20 21:46:34.042 10433-10433/com.example.bottomnavigationactivityapp I/taskId=78371 TAGMainActivityy: 2267e09: onDestroy:
十一、HomeFragment->DashFragment--返回键-->HomeFragment
返回的fragment先走到onResume。然后上一个fragment出栈,从onPause走到onDetach
2022-02-20 21:50:31.295 10433-10433/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: DashboardFragment{1664f9c} (2448c43c-f4ef-4fcd-bae0-e9196c76519d)} 2022-02-20 21:50:31.295 10433-10433/com.example.bottomnavigationactivityapp I/TAGDashboardFragment: DashboardFragment: 2022-02-20 21:50:31.303 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onAttach: 2022-02-20 21:50:31.304 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onCreate: 2022-02-20 21:50:31.309 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onActivityCreated: 2022-02-20 21:50:31.310 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onViewStateRestored: 2022-02-20 21:50:31.314 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onStart: 2022-02-20 21:50:31.316 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onResume: 2022-02-20 21:50:31.319 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onPause: 2022-02-20 21:50:31.319 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onStop: 2022-02-20 21:50:31.462 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onDestroyView: 2022-02-20 21:50:34.323 10433-10433/com.example.bottomnavigationactivityapp I/TAGHomeFragment: onCreateView: 2022-02-20 21:50:34.333 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onActivityCreated: 2022-02-20 21:50:34.334 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onViewStateRestored: 2022-02-20 21:50:34.335 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onStart: 2022-02-20 21:50:34.336 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onResume: 2022-02-20 21:50:34.339 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onPause: 2022-02-20 21:50:34.339 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onStop: 2022-02-20 21:50:34.510 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onDestroyView: 2022-02-20 21:50:34.513 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onDestroy: 2022-02-20 21:50:34.514 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onDetach:
十二、DashFragment->HomeFragment->DashFragment-->NotificationFragment--返回键-->HomeFragment
处于NotificationFragment直接返回了HomeFragment
2022-02-20 21:50:34.323 10433-10433/com.example.bottomnavigationactivityapp I/TAGHomeFragment: onCreateView: 2022-02-20 21:50:34.333 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onActivityCreated: 2022-02-20 21:50:34.334 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onViewStateRestored: 2022-02-20 21:50:34.335 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onStart: 2022-02-20 21:50:34.336 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onResume: 2022-02-20 21:50:34.339 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onPause: 2022-02-20 21:50:34.339 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onStop: 2022-02-20 21:50:34.510 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onDestroyView: 2022-02-20 21:50:34.513 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onDestroy: 2022-02-20 21:50:34.514 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 1664f9c: onDetach: home->dash 2022-02-20 21:53:40.005 10433-10433/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: DashboardFragment{8274f90} (d49bd4a4-d935-4399-85a1-3f196197b674)} 2022-02-20 21:53:40.006 10433-10433/com.example.bottomnavigationactivityapp I/TAGDashboardFragment: DashboardFragment: 2022-02-20 21:53:40.016 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onAttach: 2022-02-20 21:53:40.018 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onCreate: 2022-02-20 21:53:40.026 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onActivityCreated: 2022-02-20 21:53:40.027 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onViewStateRestored: 2022-02-20 21:53:40.028 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onStart: 2022-02-20 21:53:40.030 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onResume: 2022-02-20 21:53:40.032 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onPause: 2022-02-20 21:53:40.033 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onStop: 2022-02-20 21:53:40.182 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onDestroyView: dash-noti 2022-02-20 21:53:41.719 10433-10433/com.example.bottomnavigationactivityapp I/TAGBaseFragment: BaseFragment: NotificationsFragment{203b7b4} (772f74ba-ca90-4fb0-b628-8fad4c571abc)} 2022-02-20 21:53:41.719 10433-10433/com.example.bottomnavigationactivityapp I/TAGNotificationsFragment: NotificationsFragment: 2022-02-20 21:53:41.728 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onAttach: 2022-02-20 21:53:41.728 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onCreate: 2022-02-20 21:53:41.733 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onActivityCreated: 2022-02-20 21:53:41.733 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onViewStateRestored: 2022-02-20 21:53:41.734 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onStart: 2022-02-20 21:53:41.735 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onResume: 2022-02-20 21:53:41.737 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onPause: 2022-02-20 21:53:41.737 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onStop: 2022-02-20 21:53:41.896 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onDestroyView: 2022-02-20 21:53:41.897 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onDestroy: 2022-02-20 21:53:41.898 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGDashboardFragment 8274f90: onDetach: noti按一下返回键到home 2022-02-20 21:53:56.792 10433-10433/com.example.bottomnavigationactivityapp I/TAGHomeFragment: onCreateView: 2022-02-20 21:53:56.803 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onActivityCreated: 2022-02-20 21:53:56.804 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onViewStateRestored: 2022-02-20 21:53:56.805 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onStart: 2022-02-20 21:53:56.807 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGHomeFragment 5feae29: onResume: 2022-02-20 21:53:56.809 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onPause: 2022-02-20 21:53:56.810 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onStop: 2022-02-20 21:53:56.998 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onDestroyView: 2022-02-20 21:53:57.000 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onDestroy: 2022-02-20 21:53:57.002 10433-10433/com.example.bottomnavigationactivityapp I/getAcrivity taskId=78372 TAGNotificationsFragment 203b7b4: onDetach: