1

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.

My activity:

@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; } ... } 

The way i refer YoutubeAPI indide my fragment:

 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) {} } }); 

My refreshWindow method inside the first activity:

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(); } } 

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.

2 Answers 2

1

Well, setting the flag YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION after initialization seems to solve the problem =)

Sign up to request clarification or add additional context in comments.

Comments

1

In my case I had to reset all the flags in onInitializationSuccess, to never show the status bar at all:

player.setFullscreenControlFlags(-1); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.