Pablo
06/26/2024, 4:33 PMCalled when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created
class CustomApplication: Application() {
lateinit var container: AppContainer
lateinit var context: Context
override fun onCreate() {
super.onCreate()
container = AppContainer()
context = applicationContext
}
}
I get the Application object using this:
fun CreationExtras.CustomApplication(): CustomApplication=
(this[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY] as CustomApplication)
Zach Klippenstein (he/him) [MOD]
06/26/2024, 4:36 PMefemoney
06/26/2024, 8:02 PMAppContainer()
do? Is that a DI container? Are you sure some chain of instantiations is not somehow requiring your context
at that point?Mark Murphy
06/26/2024, 9:16 PMIt can be a problem related with ComposeI do not see how. Could you please explain? FWIW, this was cross-posted in Stack Overflow. I pointed out that `getApplicationContext()` can return `null` , notably if the process was started for the purposes of auto backup.