I have a class
public class DialogUtils
{
private Context context;
@Inject
public DialogUtils(Context context)
{
this.context = cont
On the one hand you are registering DialogUtils for Constructor Injection, so any component could provide it.
On the other hand an activity and other parts of the Android Framework still need to be field injected. Dagger can't call their constructor, and @Inject DialogUtils dialogUtils; will not just magically appear.
Here you have to use a component, and register a method that takes your components type as an argument. Dagger will then create the method to inject your activities fields.
@Component MyComponent {
inject(LoginActivity activity);
}
To inject the fields you still have to create your component, and call the inject(loginActivity) method.
void onCreate(...) {
MyComponent component = // create the component
// dagger does some heavy lifting here
component.inject(this);
dialogUtils.doSomething(); // not null, we just injected our fields
}