Having some issues with lateinit property and the ...
# android
f
Having some issues with lateinit property and the recreation of a killed Activity and its fragments... I'm initializing this property in
Activity.onCreate()
, then adding the
Fragment
, which uses this property in its
onCreate()
When the Activity is recreated after being killed, it first creates its fragments again, causing
Fragment.onCreate()
to be called before the initialization in
Activity.onCreate()
. Is there any way to fix this, or is my design wrong? I've posted this on SO as well: https://stackoverflow.com/questions/48112311/lateinit-property-not-initialized-when-activity-is-re-created
h
Would it be possible to construct the property
by lazy
instead?
f
by lazy
helped in my case, but I'm not sure if this can help in all cases in general 🤔