title: Android youtube-api cancels FLAG_FULLSCREEN in Activity
body: <p>i have designed my application to work in fullscreen mode. No status bar and no action bars are visible. This suppose a problem since every time a load a video from youtube ussing YoutubeAndroidPlayerAPI the status bar appears.</p>
  
  <p>My activity:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      overridePendingTransition(R.anim.activity_open_translate,R.anim.activity_close_scale);
  
      this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
      if(getActionBar()!=null) {
  
          ActionBar actionBar = getActionBar();
          actionBar.hide();
      }
      setContentView(R.layout.activity_fad_socios);
      ...
  }
  ...
  private void changeFragment(int index) {
  
      switch(index) {
  
          case 0:{
              getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainer, new FADFragment(),"informacion").commit();
              break;
          }
      ...
  }
  </code></pre>
  
  <p>The way i refer YoutubeAPI indide my fragment:</p>
  
  <pre><code>            fragmentManager = getActivity().getSupportFragmentManager();
              fragmentTransaction = fragmentManager.beginTransaction();
  
              fragment = new YouTubePlayerSupportFragment();
              fragmentTransaction.add(R.id.fragmentz, fragment);
              fragmentTransaction.commit();
  
                      portadaFrag.setVisibility(View.GONE);
  
                      if(buttonSelected == 0) {
  
                          ((FADSociosActivity) getActivity()).playingYoutube=true;
  
                          fragment.initialize(getActivity().getResources().getString(R.string.youKEY), new OnInitializedListener(){
  
                              @Override
                              public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) {
  
                                  Log.e("fail","fail");
                              }
  
                              @Override
                              public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1, boolean arg2) {
  
                                  youtubePlayer = arg1;
  
                                  youtubePlayer.loadVideo("-D-MVgOvvOo");
  
                                  youtubePlayer.setPlaybackEventListener(new PlaybackEventListener() {
  
                                      @Override
                                      public void onBuffering(boolean arg0) {
  
                                          try {
                                              ((FADSociosActivity) getActivity()).refreshWindow();
                                          }
                                          catch(Exception e) {}
                                      }
  
                                      @Override
                                      public void onPaused() {
  
                                          try {
                                              ((FADSociosActivity) getActivity()).playingYoutube=false;
                                              ((FADSociosActivity) getActivity()).refreshWindow();
                                          }
                                          catch(Exception e) {}
                                      }
  
                                      @Override
                                      public void onPlaying() {
  
                                          try {
  
                                              youtubePlayButton.setVisibility(View.GONE);
                                              ((FADSociosActivity) getActivity()).playingYoutube=true;
                                              ((FADSociosActivity) getActivity()).refreshWindow();
                                          }
                                          catch(Exception e) {}
                                      }
  
                                      @Override
                                      public void onSeekTo(int arg0) {
  
                                          try {
                                              ((FADSociosActivity) getActivity()).refreshWindow();
                                          }
                                          catch(Exception e) {}
                                      }
  
                                      @Override
                                      public void onStopped() {
  
                                          try {
  
                                              youtubePlayButton.setVisibility(View.VISIBLE);
                                              ((FADSociosActivity) getActivity()).playingYoutube=false;
                                              ((FADSociosActivity) getActivity()).refreshWindow();
                                          }
                                          catch(Exception e) {}
                                      }
  
                                  });
  </code></pre>
  
  <p>My refreshWindow method inside the first activity:</p>
  
  <pre><code>public void refreshWindow() {
  
      try {
  
          getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
          getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
          getWindow().getDecorView().findViewById(android.R.id.content).invalidate();
      }
      catch(Exception e) {
  
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Using this method im able to force the activity to be in fullscreen mode again after a little and undesirable tilt of the status bar. Anyway, every time the user taps over the video, the activity exits fullscreen mode. It seems that YoutubePlayer-API is overriding my FLAG_FULLSCREEN and i can't avoid this. Anyone knows how to overcome this? Thanks in advance.</p>