Android – Control orientation Android when option “Auto-rotate screen” is disable in setting

androidandroid-orientation

As you can see Youtube app for Android that can rotate screen from portrait to landscape even when option "Auto-rotate screen" is disable in setting. How can i do same it? Thank all guys!

Best Answer

Use - ActivityInfo.SCREEN_ORIENTATION_SENSOR if you want to rotate screen irrespective of user's choice else use ActivityInfo.SCREEN_ORIENTATION_USER. This will only rotate screen if its turned on.