Dagger-Non-Configuration-Scope icon indicating copy to clipboard operation
Dagger-Non-Configuration-Scope copied to clipboard

Calling retrieveInjectorOrCreateNew() after onCreate() will cause NPE in fragment

Open wingu-wiktor opened this issue 7 years ago • 0 comments

If fragment uses the same component as activity, after rotation fragment's onCreate() will be called before activity's onCreate(), causing NPE. So if you use fragment (that share the same component) this is the correct order, I believe:

injector = retrieveInjectorOrCreateNew();
super.onCreate(savedInstanceState);

Mateusz do you use it that way (fragments are using component from activity) or they have separate component ? And do you use one scope for all activities (NonConfigurationScope) ?

Ps. This way to retain presenters is very clever, thanks for your time to share this!

wingu-wiktor avatar Aug 08 '17 14:08 wingu-wiktor