/** Method that loads the UI */
  protected void loadUI(SubAppsSession subAppSession) {

    try {
      /** Get current activity to paint */
      Activity activity = getActivityUsedType();

      loadBasicUI(activity);

      if (activity.getTabStrip() == null && activity.getFragments().size() > 1) {
        initialisePaging();
      }
      if (activity.getTabStrip() != null) {
        setPagerTabs(
            getSubAppRuntimeMiddleware().getLastSubApp(), activity.getTabStrip(), subAppSession);
      }
      if (activity.getFragments().size() == 1) {
        setOneFragmentInScreen();
      }
    } catch (NullPointerException e) {
      getErrorManager()
          .reportUnexpectedUIException(
              UISource.ACTIVITY,
              UnexpectedUIExceptionSeverity.UNSTABLE,
              FermatException.wrapException(e));
      Toast.makeText(
              getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG)
          .show();
    } catch (Exception e) {
      getErrorManager()
          .reportUnexpectedUIException(
              UISource.ACTIVITY,
              UnexpectedUIExceptionSeverity.UNSTABLE,
              FermatException.wrapException(e));
      Toast.makeText(
              getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG)
          .show();
    }
  }
  /** This method catch de back bottom event and decide which screen load */
  @Override
  public void onBackPressed() {

    // get actual fragment on execute
    String frgBackType = null;
    try {
      SubAppRuntimeManager subAppRuntimeManager = getSubAppRuntimeMiddleware();

      com.bitdubai.fermat_api.layer.all_definition.navigation_structure.Fragment fragment = null;

      Activity activity = null;
      try {

        activity = subAppRuntimeManager.getLastSubApp().getLastActivity();
        fragment = activity.getLastFragment();

      } catch (NullPointerException nullPointerException) {
        fragment = null;
      }

      // get setting fragment to back
      // if not fragment to back I back to desktop

      if (fragment != null) frgBackType = fragment.getBack();

      if (frgBackType != null) {

        Activity activities = getSubAppRuntimeMiddleware().getLastSubApp().getLastActivity();

        com.bitdubai.fermat_api.layer.all_definition.navigation_structure.Fragment fragmentBack =
            activities.getFragment(frgBackType); // set back fragment to actual fragment to run

        // TODO: ver como hacer para obtener el id del container
        if (fragmentBack.getType().equals("CSADDTD")
            || fragmentBack.getType().equals("CSADDTT")
            || fragmentBack.getType().equals("CSADDTR")
            || fragmentBack.getType().equals("CSADDT")) {
          this.loadFragment(
              subAppRuntimeManager.getLastSubApp().getType(), R.id.logContainer, frgBackType);
        } else {
          this.loadFragment(
              subAppRuntimeManager.getLastSubApp().getType(), R.id.startContainer, frgBackType);
        }

      } else if (activity != null && activity.getBackActivity() != null) {
        changeActivity(activity.getBackActivity().getCode());

      } else {
        // set Desktop current activity
        activity = getSubAppRuntimeMiddleware().getLastSubApp().getLastActivity();
        if (activity.getType() != Activities.CWP_WALLET_MANAGER_MAIN) {
          resetThisActivity();
          // getSubAppRuntimeMiddleware().getHomeScreen();
          getSubAppRuntimeMiddleware().getSubApp(SubApps.CWP_WALLET_MANAGER);
          getSubAppRuntimeMiddleware()
              .getLastSubApp()
              .getActivity(Activities.CWP_WALLET_MANAGER_MAIN);
          // cleanWindows();

          loadUI(createOrCallSubAppSession());
        } else {
          super.onBackPressed();
        }
      }
    } catch (Exception e) {
      getErrorManager()
          .reportUnexpectedUIException(
              UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, e);
      Toast.makeText(
              getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG)
          .show();
    }
  }