0

I'm using Roboguice to inject my dependencies but it's not workink. I have a class that extends RoboActivity and my attribute still null.

public class SplashActivity extends RoboActivity {

    @Inject
    private PropertyReader propertyReader;

    @Inject
    Vibrator v1;

}

Should i do some aditional config?

Thank in advance.

Edit: it only works if i do RoboGuice.injectMembers in every class that i have objects to injects. Can i do it only one time for the whole app?

  • How is the activity created? Where do you access this variables (in which functions)? – mbmc Mar 21 '15 at 19:22

1 Answers1

0

You should use the injected non view fields after the activity onCreate. InjectMembers runs in super.onCreate(savedInstanceState) you dont have to call it.

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   v1.vibrate();
}

view fields should be used after onCreateView() is called.

balint.steinbach
  • 278
  • 3
  • 16