private void redirect(final boolean skipInstanceSwitcher) {
    App app = App.getAppInstance();
    Intent intent =
        new Intent(app, skipInstanceSwitcher ? TabLayout.class : InstanceSwitcherActivity.class);

    startActivity(intent);
    finish();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // render the splash screen
    setContentView(R.layout.activity_splash_screen);
    WebView wv = (WebView) findViewById(R.id.splash_webview);
    wv.loadUrl("file:///android_asset/splash_content.html");

    // The 2nd and 3rd type parameters are required but unused
    // (They would be the arguments for promise.reject and promise.progress)
    final Deferred<Bundle, Throwable, Integer> autoLoginDeferred = new DeferredObject<>();

    final Promise<Bundle, Throwable, Integer> autoLogin = autoLoginDeferred.promise();

    App.getLoginManager()
        .autoLogin(
            msg -> {
              autoLoginDeferred.resolve(msg.getData());
              return true;
            });

    Handler splashHandler =
        new Handler() {
          @Override
          public void handleMessage(Message msg) {
            autoLogin.done(
                args -> {
                  // Only skip the instance switcher for a skinned app
                  // or if the login succeeded on a non-skinned app
                  if (args != null && args.getBoolean(RestHandler.SUCCESS_KEY)) {
                    redirect(App.hasInstanceCode());
                  } else {
                    redirect(App.hasSkinCode());
                  }
                });
          }
        };
    splashHandler.sendMessageDelayed(Message.obtain(), SPLASH_SCREEN_DELAY_MILLIS);
  }