I am learning to use Roboguice and I'm having som trouble understanding how to inject a system service. All the examples I've seen is injecting into an activity but I want to inject it into a POJO. I'm using Roboguice 2.0 beta 3
I have a PhoneNumber class and would like to inject the TelephonyManager service.
public class PhoneNumber {
@Inject TelephonyManager mTelephonyManager;
protected Integer getNetworkCountryPrefix() {
// This gives a null pointer exception
mTelephonyManager.getNetworkCountryIso();
}
}
When injecting into a class that extends RoboActivity, everything works fine. But is it possible to inject the TelephonyManager in a class that doesn't extend RoboActivity?