Class AndroidSupportInjection

java.lang.Object
dagger.android.support.AndroidSupportInjection

@Beta public final class AndroidSupportInjection extends Object
Injects core Android types from support libraries.
  • Method Details

    • inject

      public static void inject(androidx.fragment.app.Fragment fragment)
      Injects fragment if an associated AndroidInjector implementation can be found, otherwise throws an IllegalArgumentException.

      Uses the following algorithm to find the appropriate AndroidInjector<Fragment> to use to inject fragment:

      1. Walks the parent-fragment hierarchy to find the a fragment that implements HasAndroidInjector, and if none do
      2. Uses the fragment's activity if it implements HasAndroidInjector, and if not
      3. Uses the Application if it implements HasAndroidInjector.
      If none of them implement HasAndroidInjector, a IllegalArgumentException is thrown.
      Throws:
      IllegalArgumentException - if no parent fragment, activity, or application implements HasAndroidInjector.