, , . , , :
@Module
public class ContextModule {
private final Context mContext;
public ContextModule(Context context) {
mContext = context;
}
@Provides
public Context provideContext() {
return mContext;
}
}
, , , .
:
@Module(entryPoints = { MyFragment.class }, includes = { ContextModule.class })
public class ServicesModule {
@Provides
public LocationManager provideLocationManager(Context context) {
return (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
}
@Provides
public Geocoder provideGeocoder(Context context) {
return new Geocoder(context);
}
}
, , , .