@Target(value=TYPE)
public @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()
}
}
HiltAndroidApp
Modifier and Type | Optional Element and Description |
---|---|
java.lang.Class<?> |
value
The base class for the generated Hilt class.
|