https://kotlinlang.org logo
Title
f

Fré Dumazy

01/05/2018, 11:10 AM
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

hallvard

01/05/2018, 1:05 PM
Would it be possible to construct the property
by lazy
instead?
f

Fré Dumazy

01/05/2018, 1:38 PM
by lazy
helped in my case, but I'm not sure if this can help in all cases in general 🤔