In my android application I have a strange bug. An instance variable like below gets assigned to it\'s default value unexpectedly at run time (in this case - false). When do thi
Instance variables in Java are initialized when the instance is created.
Most of the time objects would get instantiated with new
.
In case of activities, they are instantiated by the Android framework using reflection (see Instrumentation#newActivity()). Then initialization for Context
is performed and activity onCreate()
gets called on the instance.
For details, have a look at ActivityThread source.