@Override
  protected void onResume() {
    super.onResume();

    if (mReactInstanceManager != null) {
      mReactInstanceManager.onResume(this);
    }
  }
  @Override
  protected void onResume() {
    super.onResume();

    mLifecycleState = LifecycleState.RESUMED;

    if (mReactInstanceManager != null) {
      mReactInstanceManager.onResume(this, this);
    }
  }
  public void loadApp(
      String appKey,
      ReactInstanceSpecForTest spec,
      @Nullable Bundle initialProps,
      String bundleName,
      boolean useDevSupport) {

    final CountDownLatch currentLayoutEvent = mLayoutEvent = new CountDownLatch(1);
    mBridgeIdleSignaler = new ReactBridgeIdleSignaler();

    ReactInstanceManager.Builder builder =
        ReactTestHelper.getReactTestFactory()
            .getReactInstanceManagerBuilder()
            .setApplication(getApplication())
            .setBundleAssetName(bundleName)
            // By not setting a JS module name, we force the bundle to be always loaded from
            // assets, not the devserver, even if dev mode is enabled (such as when testing
            // redboxes).
            // This makes sense because we never run the devserver in tests.
            // .setJSMainModuleName()
            .addPackage(
                spec.getAlternativeReactPackageForTest() != null
                    ? spec.getAlternativeReactPackageForTest()
                    : new MainReactPackage())
            .addPackage(new InstanceSpecForTestPackage(spec))
            .setUseDeveloperSupport(useDevSupport)
            .setBridgeIdleDebugListener(mBridgeIdleSignaler)
            .setInitialLifecycleState(mLifecycleState);

    mReactInstanceManager = builder.build();
    mReactInstanceManager.onResume(this, this);

    Assertions.assertNotNull(mReactRootView)
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                currentLayoutEvent.countDown();
              }
            });
    Assertions.assertNotNull(mReactRootView)
        .startReactApplication(mReactInstanceManager, appKey, initialProps);
  }