/**
   * Builds and displays a licenses fragment with or without a Close button. Requires
   * "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" to be present.
   *
   * @param fm A fragment manager instance used to display this LicensesFragment.
   * @param showCloseButton Whether to show a Close button at the bottom of the dialog.
   */
  public static void displayLicensesFragment(FragmentManager fm, boolean showCloseButton) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG);
    if (prev != null) {
      ft.remove(prev);
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    DialogFragment newFragment = LicensesFragment.newInstance(showCloseButton);
    newFragment.show(ft, FRAGMENT_TAG);
  }