@Override
  protected void onCreate(Bundle savedInstanceState) {
    if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, this + " onCreate");

    float fontScale = getResources().getConfiguration().fontScale;
    if (sLastFontScale != -1 && sLastFontScale != fontScale) {
      // If the font scale has been initialized, and has been detected to be different than
      // the last time the Activity ran, it means the user changed the font while no
      // Email Activity was running - we still need to purge static information though.
      onFontScaleChangeDetected();
    }
    sLastFontScale = fontScale;

    // UIController is used in onPrepareOptionsMenu(), which can be called from within
    // super.onCreate(), so we need to initialize it here.
    initUIController();

    super.onCreate(savedInstanceState);
    ActivityHelper.debugSetWindowFlags(this);

    final Intent intent = getIntent();
    boolean fromKeyguard = intent.getBooleanExtra(EXTRA_FROM_KEYGUARD, false);
    if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) {
      Log.d(Logging.LOG_TAG, "FLAG_DISMISS_KEYGUARD " + fromKeyguard);
    }
    if (fromKeyguard) {
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    }

    setContentView(mUIController.getLayoutId());

    mUIController.onActivityViewReady();

    mController = Controller.getInstance(this);
    mControllerResult =
        new ControllerResultUiThreadWrapper<ControllerResult>(
            new Handler(), new ControllerResult());
    mController.addResultCallback(mControllerResult);

    // Set up views
    // TODO Probably better to extract mErrorMessageView related code into a separate class,
    // so that it'll be easy to reuse for the phone activities.
    TextView errorMessage = (TextView) findViewById(R.id.error_message);
    errorMessage.setOnClickListener(this);
    int errorBannerHeight = getResources().getDimensionPixelSize(R.dimen.error_message_height);
    mErrorBanner = new BannerController(this, errorMessage, errorBannerHeight);

    if (savedInstanceState != null) {
      mUIController.onRestoreInstanceState(savedInstanceState);
    } else {
      final MessageListContext viewContext = MessageListContext.forIntent(this, intent);
      if (viewContext == null) {
        // This might happen if accounts were deleted on another thread, and there aren't
        // any remaining
        Welcome.actionStart(this);
        finish();
        return;
      } else {
        final long messageId = intent.getLongExtra(EXTRA_MESSAGE_ID, Message.NO_MESSAGE);
        mUIController.open(viewContext, messageId);
      }
    }
    mUIController.onActivityCreated();
  }