This is the most important question for interview point of view.
Case 1: When not use "addToBackStack()" and use "add" method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate to B_Fragment
B_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Click the Next button to navigate to C_Fragment
Back button click
A_Fragment: onPause()
B_Fragment: onPause()
C_Fragment: onPause()
MainActivity : onPause()
A_Fragment: onStop()
B_Fragment: onStop()
C_Fragment: onStop()
MainActivity : onStop()
A_Fragment: onDestroyView()
A_Fragment: onDestroy()
A_Fragment: onDettach()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
MainActivity : onDestroy()
Case 2: When use "addToBackStack()" and use "add" method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate to B_Fragment
B_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Click the Next button to navigate to C_Fragment
C_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
C_Fragment: onPause()
C_Fragment: onStop()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
Again Back button click
B_Fragment: onPause()
B_Fragment: onStop()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
Again Back button click
A_Fragment: onPause()
A_Fragment: onStop()
A_Fragment: onDestroyView()
A_Fragment: onDestroy()
A_Fragment: onDettach()
Again Back button click
MainActivity : onPause() -- onStop() -- onDestroy()
Case 2: When use "addToBackStack()" and use "add" and "replace"method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate to B_Fragment
B_Fragment : onAttach() -- onCreate() -- onCreateView() -- onViewCreated() -- onActivityCreated() -- onStart() -- onResume()
Click the Next button to navigate B to C_Fragment using "replace" method
C_Fragment : onAttach() --onCreate()
B_Fragment : onPause() -- onStop() -- onDestroyView()
C_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
C_Fragment: onPause()
C_Fragment: onStop()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
A_Fragment: onCreateView()
A_Fragment: onViewCreated()
A_Fragment: onActivityCreated()
A_Fragment: onStart()
A_Fragment: onResume()
B_Fragment: onCreateView()
B_Fragment: onViewCreated()
B_Fragment: onActivityCreated()
B_Fragment: onStart()
B_Fragment: onResume()
Again Back button click
B_Fragment: onPause()
B_Fragment: onStop()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
Again Back button click
A_Fragment: onPause()
A_Fragment: onStop()
A_Fragment: onDestroyView()
A_Fragment: onDestroy()
A_Fragment: onDettach()
Again Back button click
MainActivity : onPause() -- onStop() -- onDestroy()
Case 3: When not use "addToBackStack()" and use "replace"method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate A_Fragment to B_Fragment
B_Fragment : onAttach() -- onCreate()
A_Fragment : onPause() -- onStop() -- onDestroyView() -- onDestroy()
B_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Click the Next button to navigate B_Fragment to C_Fragment
C_Fragment : onAttach() -- onCreate()
B_Fragment : onPause() -- onStop() -- onDestroyView() -- onDestroy()
C_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
C_Fragment : onPause()
MainActivity : onPause()
C_Fragment : onStop()
MainActivity : onStop()
C_Fragment : onDestroyView() -- onDestroy() -- onDettach()
MainActivity : onDestroy()
Case 3: When use "addToBackStack()" and use "replace"method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate A_Fragment to B_Fragment
B_Fragment : onAttach() -- onCreate()
A_Fragment : onPause() -- onStop() -- onDestroyView()
B_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Click the Next button to navigate B_Fragment to C_Fragment
C_Fragment : onAttach() -- onCreate()
B_Fragment : onPause() -- onStop() -- onDestroyView()
C_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
C_Fragment: onPause()
C_Fragment: onStop()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
B_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
B_Fragment: onPause()
B_Fragment: onStop()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
A_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
Thanks
Case 1: When not use "addToBackStack()" and use "add" method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate to B_Fragment
B_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart() -- onResume()
C_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
A_Fragment: onPause()
B_Fragment: onPause()
C_Fragment: onPause()
MainActivity : onPause()
A_Fragment: onStop()
B_Fragment: onStop()
C_Fragment: onStop()
MainActivity : onStop()
A_Fragment: onDestroyView()
A_Fragment: onDestroy()
A_Fragment: onDettach()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
MainActivity : onDestroy()
Case 2: When use "addToBackStack()" and use "add" method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate to B_Fragment
B_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart() -- onResume()
C_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
C_Fragment: onPause()
C_Fragment: onStop()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
Again Back button click
B_Fragment: onPause()
B_Fragment: onStop()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
Again Back button click
A_Fragment: onPause()
A_Fragment: onStop()
A_Fragment: onDestroyView()
A_Fragment: onDestroy()
A_Fragment: onDettach()
Again Back button click
MainActivity : onPause() -- onStop() -- onDestroy()
Case 2: When use "addToBackStack()" and use "add" and "replace"method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate to B_Fragment
B_Fragment : onAttach() -- onCreate() -- onCreateView() -- onViewCreated() -- onActivityCreated() -- onStart() -- onResume()
C_Fragment : onAttach() --onCreate()
B_Fragment : onPause() -- onStop() -- onDestroyView()
A_Fragment : onPause() -- onStop() -- onDestroyView()
Back button click
C_Fragment: onPause()
C_Fragment: onStop()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
A_Fragment: onCreateView()
A_Fragment: onViewCreated()
A_Fragment: onActivityCreated()
A_Fragment: onStart()
A_Fragment: onResume()
B_Fragment: onCreateView()
B_Fragment: onViewCreated()
B_Fragment: onActivityCreated()
B_Fragment: onStart()
B_Fragment: onResume()
Again Back button click
B_Fragment: onPause()
B_Fragment: onStop()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
Again Back button click
A_Fragment: onPause()
A_Fragment: onStop()
A_Fragment: onDestroyView()
A_Fragment: onDestroy()
A_Fragment: onDettach()
MainActivity : onPause() -- onStop() -- onDestroy()
Case 3: When not use "addToBackStack()" and use "replace"method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate A_Fragment to B_Fragment
B_Fragment : onAttach() -- onCreate()
A_Fragment : onPause() -- onStop() -- onDestroyView() -- onDestroy()
B_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Click the Next button to navigate B_Fragment to C_Fragment
C_Fragment : onAttach() -- onCreate()
B_Fragment : onPause() -- onStop() -- onDestroyView() -- onDestroy()
C_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
C_Fragment : onPause()
MainActivity : onPause()
C_Fragment : onStop()
MainActivity : onStop()
C_Fragment : onDestroyView() -- onDestroy() -- onDettach()
MainActivity : onDestroy()
Case 3: When use "addToBackStack()" and use "replace"method
MainActivity : onCreate()
A_Fragment : onAttach() -- onCreate() -- onCreateView() -- onActivityCreated() -- onStart()
MainActivity : onStart() -- onResume()
A_Fragment: onResume()
Click the Next button to navigate A_Fragment to B_Fragment
B_Fragment : onAttach() -- onCreate()
A_Fragment : onPause() -- onStop() -- onDestroyView()
B_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Click the Next button to navigate B_Fragment to C_Fragment
C_Fragment : onAttach() -- onCreate()
B_Fragment : onPause() -- onStop() -- onDestroyView()
C_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
C_Fragment: onPause()
C_Fragment: onStop()
C_Fragment: onDestroyView()
C_Fragment: onDestroy()
C_Fragment: onDettach()
B_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
B_Fragment: onPause()
B_Fragment: onStop()
B_Fragment: onDestroyView()
B_Fragment: onDestroy()
B_Fragment: onDettach()
A_Fragment : onCreateView() -- onActivityCreated() -- onStart() -- onResume()
Back button click
MainActivity : onPause() -- onStop() -- onDestroy()
Thanks
No comments:
Post a Comment