Fragment Lifecycle With Respect To It's Activity
Solution 1:
The official documentation for the Fragment lifecycle explains this clearly - please refer to it and then ask follow-up questions if something is unclear.
Solution 2:
This Image will be helpful to understand both life cycles together.
As many people complaints and it is somewhat valid argument that this life cycle is too complicated, in Google I/O 2018,They have suggested to use Architecture component Framework. Please check this Docs
Solution 3:
when you are at Activity2---->backpress--->Fragment2(Activity1)
---means Activity1
again attach from fragment2
so on OnAactivityCreated()
method Activity1
is completely loaded ....so at that we can call setData()
method of your Activity1...
Solution 4:
onAttachFragment()-activity is called before onCreate()-activity and after onAttach()-fragment
Solution 5:
Call onDestroy on onStop of your fragment. This should call onCreate when the fragment is launched. Let me know if works as an ideal solution for your problem.
Post a Comment for "Fragment Lifecycle With Respect To It's Activity"