Reputation: 4821
I'm using a custom context on an Android app and I'm using Roboguice for injection (I use ActionBarSherlock, so I'm using robosherlock)
This custom context is using some fields that are initialized when onCreate is called.
Next, I have a Fragment whose signature looks like this:
public class CustomFragment extends RoboSherlockListFragment
and I try to inject my custom context:
@Inject
private CustomContext mContext;
When I try to acces the private field initialized on CustomApplication's context with a getPrivateField() method, I get null like if the context was new and not reusing the old one.
Could someone help me?
Thanks!
Upvotes: 0
Views: 134
Reputation: 3429
I don't know how this CustomContext
of yours exactly works, but when RoboGuice encounters an @Inject
annotation for which it doesn't have a specific binding rule (a bind(CustomContext.class)
line in your module), then it just creates a new object using the default constructor.
You should probably create a custom Provider which contains the logic of where to get this specific CustomContext.
Upvotes: 1