If I have a class with a single constructor, how can I get Roboguice to inject this into an activity?
The service to be injected:
public FlightManager(Context context){
//do something with the context
}
The activity:
public class recordFlight extends RoboActivity {
@InjectResource FlightManager manager;
//whatever code here
}
The only dependency is the Context, which I gather should be injected without problem. Additoinally, all of my other usages, such as @InjectView and @Inject of classes with a default constructor seem fine, but the usage above kills the app without even giving me a stack trace.
Any ideas?
Thanks
Jon
Mark the constructor with the @Inject annotation:
Then inject FlightManager like so:
@InjectResource is not necessary here, since it’s a regular Java class you’re injecting, not an Android resource.