JozeRi JozeRi - 1 year ago 80
Android Question

Full-screen goes out when switching to portrait

I am using Youtube API for android app and I'm looking for a way to avoid exiting full-screen mode while switching between landscape modes. Meaning, I don't want to exit full-screen mode while switching the phone to portrait mode. I need the video to always be on full-screen.

Is there a way to make it happen?

My current code for full screen is:

public void onInitializationSuccess(YouTubePlayer.Provider provider,
YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
Intent intent = getIntent();
String Video_Link = intent.getStringExtra("youtube_id");

Thanks a lot in advance.

Answer Source

On an orientation change, the onCreate method is called. You could try adding this line within the Activity in question in your Manifest file to prevent the onCreate call.


and it might maintain the fullscreen status of youtube for you...

otherwise you might try overriding the onconfigchange method:

@Override //reconfigure display properties on screen rotation
    public void onConfigurationChanged(Configuration newConfig) {

            //Checks the orientation of the screen
            if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) 
                // handle change here
            else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
                // or here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download