Annotation Type CustomInject

  • @Target(TYPE)
    public @interface CustomInject
    When used on a HiltAndroidApp-annotated application, this causes the application to no longer inject itself in onCreate and instead allows it to be injected at some other time.

    When using this annotation, you can use CustomInjection.inject( to inject the application class. Additionally, this annotation will also cause a method, customInject to be generated in the Hilt base class as well, that behaves the same as CustomInjection.inject( The method is available to users that extend the Hilt base class directly and don't use the Gradle plugin.

    Example usage:

     public final class MyApplication extends Hilt_MyApplication {
       @Inject Foo foo;
       public void onCreate() {
         // Injection would normally happen in this super.onCreate() call, but won't now because this
         // is using CustomInject.
         // This call now injects the fields in the Application, like the foo field above.