Has the order of instantiation of objects (applica...
# compose-android
m
Has the order of instantiation of objects (application and activity) changed under compose? I'm using "application" in my base activity class and now I'm starting ("trying") to use compose in my build it's being reported as null in the initialisation of the base activity. This didn't happen previously. How can I get a reference to the application in the init of the activity? During "onStart" is too late and I haven't seen another method that looks promising.
m
Has the order of instantiation of objects (application and activity) changed under compose?
Assuming that by "application" you mean the
Application
singleton, then no. That's set by the OS and framework.
How can I get a reference to the application in the init of the activity?
If by "init" you mean an
init()
block, that is not possible, as the activity instance is not wired into the rest of the framework yet.
During "onStart" is too late and I haven't seen another method that looks promising.
onCreate()
, after the
super.onCreate()
call, happens before
onStart()
.
m
Thanks for that @Mark Murphy I mean
android.app.Activity
public final android.app.Application getApplication()
Return the application that owns this activity.
onCreate seems not to be early enough either 😞
m
There really isn't anything earlier than
onCreate()
for an
Activity
, so you may want to focus on why you think that you need something earlier and why you think Compose is tied into this. For example, if you are trying to reference the
Application
from a property initializer, that will not work, but that hasn't worked since Android 1.0.