title: How to mock activity dependencies in an instrumentation test
body: <p>I want to get a reference to my activity before it is created in order to inject some mocks. </p>
  
  <p>So I have my activity test rule like:</p>
  
  <pre><code>   ActivityTestRule mActivityRule = new ActivityTestRule&lt;MainActivity&gt;(MainActivity,class, true, false)
  </code></pre>
  
  <p>I know that ActivityTestRule has a beforeActivityLaunched callback, but there I cant get any reference to my activity (is null there). </p>
  
  <p>So if I do:</p>
  
  <pre><code>@Rule
  public ActivityTestRule&lt;MainActivity&gt; mActivityTestRule = new ActivityTestRule(
          MainActivity.class) {
      @Override
      protected void beforeActivityLaunched() {
          super.beforeActivityLaunched();
          MainActivity act = (MainActivity)getActivity();
           //Here act is null
  </code></pre>
  
  <p>I cannot get a reference to my activity in the setUp method of my test class either. Activity reference is ready only when I do rule.launchActivity(), but then Activity is executed and I cannot pass any dependencies before. I know that I can use dagger for that, but I want to avoid it for this case. Is there any way to prepare the activity dependencies without dagger before it is launched?</p>