Retaining Dagger 2 Subcomponent
Is it possible to retain a Dagger 2 subcomponent for an activity through a configuration change? It seems like the only two possible solutions are:
- to use a retained Fragment, or
- to save the state of the objects in the subcomponent and restore it using the savedInstanceState
Both seem like messy solutions - has anyone solved this problem with a cleaner solution?
Your question sounds like something that you should not try to do.
A component that is created and dependent on the activity will likely have a reference to the activity. Retaining that component sounds like a primary cause for memory leaks.
When your configuration changes, the activity is destroyed and everything associated with it should also be destroyed.
So what you mentioned—saving the state in the bundle
onSaveInstanceState and recreating it again—sounds like the cleanest solution to me.
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View