public void detectFragment() {
    FragmentB fragment = (FragmentB) getFragmentManager().findFragmentById(R.id.fragB);
    if (fragment == null || !fragment.isInLayout()) {
      TextView tv = (TextView) findViewById(R.id.buttonFragA);
      tv.setText("PORTRAIT");

    } else {
      TextView tv = (TextView) findViewById(R.id.buttonFragA);
      tv.setText("LAND");
    }
  }