title: Android add Tabs in FragmentActivity tabHost on condition
body: <p>So i am making a simple application about ciphers and here is what i am trying to do:</p>
  
  <pre><code>Bundle extras = getIntent().getExtras();
  szyfr = extras.getString("szyfr");
  </code></pre>
  
  <p>I am passing a variable from main activity depending on what the user is going to choose and now I have a problem.</p>
  
  <p>I want to create 3 tabs if my variable is equal to "Cezar" and 4 tabs if my variable is equal to "OTP". I was trying to use simple IF condition but it isn't really working(I checked if the variable is passed properly and it is). All this is done in OnCreate of FragmentActivity class.</p>
  
  <pre><code>private FragmentTabHost mTabHost;
  
  mTabHost = (FragmentTabHost) findViewById(R.id.tabhost);
  
      mTabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);
  
      mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("Historia"),
              OTPFragment1.class, null);
  
      mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("Szyfrowanie"),
              OTPFragment2.class, null);
  
      mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("Deszyfrowanie"),
              OTPFragment3.class, null);
  
      if(szyfr=="OTP")
      {
      mTabHost.addTab(mTabHost.newTabSpec("tab4").setIndicator("Inne"),
              OTPFragment4.class, null);
      }
  </code></pre>
  
  <p>As you can see i have a different fragment for each tab and they all show up properly but if i use this condition only 3 of them show up every time, no matter what the user is going to choose.</p>
  
  <p>Variable passed this way if anybody needs to make sure it works:</p>
  
  <pre><code>Intent intent = new Intent(MainActivity.this, OTP.class);
                  intent.putExtra("szyfr", "OTP");
                  startActivity(intent);
  </code></pre>
  
  <p>I don't think programmatically adding tabs is the answer here because I want my tabs to be the same every time but sometimes I want an additional tab.</p>