I have my NetworkDataSource
which I want to inject. I want to use constructor injection because I'm the owner of this class:
public class NetworkDataSource {
@Inject
public NetworkDataSource(String url, String method) {
this.url = url;
this.method = method;
}
}
The thing is that the arguments of this constructor (which are the dependencies) are retrieved from a Service
as extras when a BroadcastIntent
is triggered. So my question is, how could I provide these arguments retrieved from the Service
to my NetworkDataSource
constructor injection?
The Service
looks like this:
public class Service extends IntentService {
// I would like to inject NetworkDataSource
//@Inject
//NetworkDataSource netWorkDataSource;
public String url;
public String method;
@Override
protected void onHandleIntent(Intent workIntent) {
url = workIntent.getStringExtra("url");
method = workIntent.getStringExtra("method");
}
............
............
networkDataSource.myMethod();
}
Thank you.