6 ms·
How do you set those variables? Do you keep a reference to your activity or fragment inside another screen? Do you clean up that reference on configuration chan
by lubonay 6y ago
How do you set those variables? Do you keep a reference to your activity or fragment inside another screen? Do you clean up that reference on configuration change, or let it leak and/or cause crashes?
Your best bet to pass data around is to... not pass it but rather use a sophisticated DI setup where you can set up shared objects that live in a certain scope. Of course, you can add parameters to a bundle with some boilerplate, but that's not a great idea if the serialization overhead hurts you.
- kllrnohj 6y agoNeither the ViewModel library nor Activity#onRetainNonConfigurationInstance() is what I'd call a "sophisticated DI setup"