Annotation Interface 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(android.app.Application) 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(android.app.Application). The method is available to users that extend the Hilt base class directly and don't use the Gradle plugin.

Example usage:


 @CustomInject
 @HiltAndroidApp(Application.class)
 public final class MyApplication extends Hilt_MyApplication {

   @Inject Foo foo;

   @Override
   public void onCreate() {
     // Injection would normally happen in this super.onCreate() call, but won't now because this
     // is using CustomInject.
     super.onCreate();
     doSomethingBeforeInjection();
     // This call now injects the fields in the Application, like the foo field above.
     CustomInject.inject(this);
   }
 }