1
我有一個具有以下結構的類。Dagger - Inject同時向字段變量和構造函數提供bean
在Dagger中,它是「合法的」@同時在域變量和構造函數中注入bean,正如我在下面所做的那樣?如果不是 - 我有一個MyActivityModule和MyApplicationModule,如何從MyApplicationModule獲取依賴關係並將它們添加到我在MyActivityModule的provideWhatEvery中使用的構造函數中?
@Inject SmsFormatter mSmsFormatter;
@Inject SmsGuardiansUtils smsGuardiansUtils;
@Inject BipperMediaPlayer bipperMediaPlayer;
@Inject MixPanelUtils mMixpanelUtils;
@Inject
public ImHereController(View view, Context context, AlarmModel alarmModel, ActionBarListener actionBarListener,
FragmentController fragmentController){
super(view, context, alarmModel, actionBarListener, fragmentController);
}
再次測試它,它工作,設法通過字段變量和通過構造函數添加! 。不知道爲什麼它沒有起作用,我開始瞭解如何將這些零件連接在一起之前,必須在開始時錯誤地配置了這些bean。 感謝您的幫助:) –