title: How to access injected properties in attachBaseContext using Hilt?
body: <p>For the sake of changing application's default <code>Locale</code>, I have to get access of my <code>WrapContext</code> class in <code>attachBaseContext</code> method inside the <strong>Activity</strong>:</p>
  <pre><code>@AndroidEntryPoint
  class MainActivity : AppCompatActivity() {
  
      @Inject lateinit var wrapper: WrapContext
  
      .
      .
      .
  
      override fun attachBaseContext(newBase: Context?) {
          super.attachBaseContext(wrapper.setLocale(newBase!!))
      }
  }
  </code></pre>
  <p>But as you can imagine I get <code>nullPointerException</code> because the field is injected after <code>attachBaseContext</code> is called.</p>
  <p>Here is the <strong>WrapContext</strong> class:</p>
  <pre><code>@Singleton
  class WrapContext @Inject constructor() {
  
      fun setLocale(context: Context): Context {
          return setLocale(context, language)
      }
  
      .
      .
      .
  }
  </code></pre>
  <p>I also tried to inject <strong>WrapContext</strong> inside <strong>MyApp</strong> class so the field should be initialized when calling it inside <strong>Activity</strong>.</p>
  <pre><code>@HiltAndroidApp
  class MyApp : Application() {
      @Inject lateinit var wrapper: WrapContext
  }
  </code></pre>
  <p><code>attachBaseContext</code> inside activity:</p>
  <pre><code>override fun attachBaseContext(newBase: Context?) {
      super.attachBaseContext((applicationContext as MyApp).wrapper.setLocale(newBase!!))
  }
  </code></pre>
  <p>But I still get the same error. I debugged the code and I found that <code>applicationContext</code> is <strong>Null</strong> in the method.</p>
  <p>I searched online and I found the same issue someone had with <code>dagger</code> <a href="https://stackoverflow.com/questions/50716906/using-dagger-injected-objects-in-attachbasecontext">here</a>. But there is no accepted answer which can maybe give me some sights to do it in <code>hilt</code>.</p>
  <p>Is there a way to get this <code>WrapContext</code> class in the <code>attachBaseContext</code> method inside activity?</p>