What are the differences between onCreate()
, onCreateView()
, and onActivityCreated()
in fragments and what would they each be used for?
This question is related to
android
android-fragments
android-lifecycle
oncreate
fragment-lifecycle
For anyone looking for a concise, pictorial answer:
https://hanaskuliah.wordpress.com/2015/12/07/android-5-development-part-6-fragment/
And,
onActivityCreated()
is now deprecated as Fragments Version 1.3.0-alpha02
The onActivityCreated() method is now deprecated. Code touching the fragment's view should be done in onViewCreated() (which is called immediately before onActivityCreated()) and other initialization code should be in onCreate(). To receive a callback specifically when the activity's onCreate() is complete, a LifeCycleObserver should be registered on the activity's Lifecycle in onAttach(), and removed once the onCreate() callback is received.
Detailed information can be found here
Source: Stackoverflow.com