protected void onCreate(Bundle savedInstanceState) {
MyAppComponent parentComponent = ((MyApp) getApplication()).component();
injectMembers(parentComponent);
}
protected abstract void injectMembers(MyAppComponent parentComponent);
@Override protected void injectMembers(MyAppComponent parentComponent) {
// with a subcomponent:
parentComponent.plus(new Module1()).inject(this);
// or with a component with dependencies:
// DaggerMyClassComponent.builder()
// .myAppComponent(parentComponent)
// .build()
// .inject(this);
}
}
In any case, you need members-injection methods on components for each of your subclass (instead of listing those classes in the injects of the @Module annotation in Dagger 1), and you need to call the appropriate one (see the "note about covariance" in @Component javadoc). This is where Bullet• can help (dynamically selecting the appropriate method to call), but Bullet• is only a crutch and you should refactor your code to avoid it instead (as I show above).