Annotation Interface AndroidEntryPoint
This annotation will generate a base class that the annotated class should extend, either
directly or via the Hilt Gradle Plugin. This base class will take care of injecting members into
the Android class as well as handling instantiating the proper Hilt components at the right point
in the lifecycle. The name of the base class will be "Hilt_ Example usage (with the Hilt Gradle Plugin):
Example usage (without the Hilt Gradle Plugin):
@AndroidEntryPoint
public final class FooActivity extends FragmentActivity {
@Inject Foo foo;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // The foo field is injected in super.onCreate()
}
}
@AndroidEntryPoint(FragmentActivity.class)
public final class FooActivity extends Hilt_FooActivity {
@Inject Foo foo;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // The foo field is injected in super.onCreate()
}
}
- See Also:
-
Optional Element Summary
-
Element Details
-
value
Class<?> valueThe base class for the generated Hilt class. When applying the Hilt Gradle Plugin this value is not necessary and will be inferred from the current superclass.- Default:
- java.lang.Void.class
-