private void setOneFragmentInScreen() throws InvalidParameterException {

    SubAppRuntimeManager subAppRuntimeManager = getSubAppRuntimeMiddleware();
    SubApps subAppType = subAppRuntimeManager.getLastSubApp().getType();

    com.bitdubai.fermat_android_api.layer.definition.wallet.interfaces.SubAppFragmentFactory
        subAppFragmentFactory = SubAppFragmentFactory.getFragmentFactoryBySubAppType(subAppType);
    String fragment =
        subAppRuntimeManager.getLastSubApp().getLastActivity().getLastFragment().getType();
    SubAppsSession subAppsSession = getSubAppSessionManager().getSubAppsSession(subAppType);

    try {
      if (subAppFragmentFactory != null) {

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.setVisibility(View.GONE);

        ViewPager pagertabs = (ViewPager) findViewById(R.id.pager);
        pagertabs.setVisibility(View.VISIBLE);

        adapter =
            new TabsPagerAdapter(
                getFragmentManager(),
                getApplicationContext(),
                subAppFragmentFactory,
                fragment,
                subAppsSession,
                getSubAppResourcesProviderManager(),
                getResources());
        pagertabs.setAdapter(adapter);

        final int pageMargin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        pagertabs.setPageMargin(pageMargin);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  private SubAppsSession createOrCallSubAppSession() {
    SubAppsSession subAppSession = null;
    try {
      Bundle bundle = getIntent().getExtras();
      SubApps installedSubApp = null;
      if (bundle != null) {
        if (bundle.containsKey(INSTALLED_SUB_APP)) {
          installedSubApp =
              ((InstalledSubApp) bundle.getSerializable(INSTALLED_SUB_APP)).getSubAppType();
        } else if (bundle.containsKey(ConnectionConstants.SUB_APP_CONNECTION)) {
          installedSubApp =
              (SubApps) bundle.getSerializable(ConnectionConstants.SUB_APP_CONNECTION);
        }
      }
      if (installedSubApp != null) {
        if (getSubAppSessionManager().isSubAppOpen(installedSubApp)) {
          subAppSession = getSubAppSessionManager().getSubAppsSession(installedSubApp);
        } else {
          ManagerFactory managerFactory =
              new ManagerFactory(((ApplicationSession) getApplication()).getFermatSystem());
          subAppSession =
              getSubAppSessionManager()
                  .openSubAppSession(
                      installedSubApp,
                      getErrorManager(),
                      managerFactory.getModuleManagerFactory(installedSubApp));
        }
      }

    } catch (NullPointerException nullPointerException) {
      getErrorManager()
          .reportUnexpectedUIException(
              UISource.ACTIVITY,
              UnexpectedUIExceptionSeverity.UNSTABLE,
              FermatException.wrapException(nullPointerException));
    } catch (Exception e) {
      e.printStackTrace();
      // this happend when is in home screen
    }
    return subAppSession;
  }