0

How do i inject the current Activity context into my object? I've tried using the @Inject annotation when declaring the instance variable as well as in the constructor of the object but it seems RoboGuice is injecting the wrong one or creating a new Activity object.

07-09 13:58:02.110: WARN/System.err(21352): com.google.inject.ProvisionException: Guice provision errors:
07-09 13:58:02.110: WARN/System.err(21352): [ 07-09 13:58:02.110 21352:21352 W/System.err ]
        1) null returned by binding at roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:131)
07-09 13:58:02.110: WARN/System.err(21352): but parameter 0 of com.myapp.utility.NavigateAppAction.<init>() is not @Nullable
07-09 13:58:02.110: WARN/System.err(21352): while locating roboguice.inject.NullProvider<android.app.Activity>
07-09 13:58:02.110: WARN/System.err(21352): at roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:131)
07-09 13:58:02.110: WARN/System.err(21352): while locating android.app.Activity
07-09 13:58:02.110: WARN/System.err(21352): for parameter 0 at com.myapp.utility.NavigateAppAction.<init>(Unknown Source)
07-09 13:58:02.110: WARN/System.err(21352): while locating com.myapp.utility.NavigateAppAction
David
  • 10,418
  • 17
  • 72
  • 122

1 Answers1

0

If you @Inject Activity or Context, it should inject the current activity because RoboGuice ships with a binding for Activity and Context. However, if you try to @Inject MySpecificActivitySubclass, you'll need to set up your own binding.

emmby
  • 99,783
  • 65
  • 191
  • 249