I just started using Roboguice (+Guice) and I am not sure about the best practice how to use it.
In my Activity I have about 5 functions (out of about 30) which uses an object called "ProviderQueries" (Singleton). I could use it in two ways:
1.)
protected void onResume() {
super.onResume();
getInjector().getInstance(ProviderQueries.class).setLanguage("EN");
}
2.)
class MyActivity extends RoboActivity {
@Inject
private ProviderQueries pv;
...
protected void onResume() {
super.onResume();
pv.setLanguage("EN");
}
}
1 - too long but the instance of ProviderQueries is used where it is needed
2 - short and nice but "pv" is available for the whole Activity but only needed in 5 different function...
Which approach would you use, or do you have a better solution?
Thanks in advance!