所以我试图将需要上下文的类注入到演示者中,但是我得到了
CallingActivity)] android.content.Context cannot be provided without an @Provides-annotated method.
这是我的组件:
@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
@ApplicationContext
Context context();
Application application();
DataManager apiManager();
}
这是我的ConfigPersistentComponent:
@ConfigPersistent
@Component(dependencies = AppComponent.class)
public interface ConfigPersistentComponent {
ActivityComponent activityComponent(ActivityModule activityModule);
FragmentComponent fragmentComponent(FragmentModule fragmentModule);
ServiceComponent serviceComponent(ServiceModule serviceModule);
}
这是我要添加到演示者中的课程:
@Singleton
public class SpeechRecognizerUtil {
private Context context;
private SpeechListener speechListener;
private IRemote mService;
private ServiceConnection mServiceConnection;
@Inject
public SpeechRecognizerUtil(Context context) {
this.context = context;
}
....
这是我的演示者:
@ConfigPersistent
public class CallingPresenter extends BasePresenter<CallingMvpView> implements SpeechRecognizerUtil.SpeechListener {
private final DataManager dataManager;
private final SpeechRecognizerUtil speechRecognizerUtil;
@Inject
public CallingPresenter(DataManager dataManager, SpeechRecognizerUtil speechRecognizerUtil) {
this.dataManager = dataManager;
this.speechRecognizerUtil = speechRecognizerUtil;
}
.....
我做错了什么?,谢谢。