Annotation Type AndroidEntryPoint
-
@Target(TYPE) public @interface AndroidEntryPoint
Marks an Android component class to be setup for injection with the standard Hilt Dagger Android components. Currently, this supports activities, fragments, views, services, and broadcast receivers.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):
@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() } }
Example usage (without the Hilt Gradle Plugin):
@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:
HiltAndroidApp
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>
value
The base class for the generated Hilt class.
-