I'm trying to achieve this behaviour:
- When I rotate the device to landscape, the screen does it too.
- To get it back to portrait there are two ways:
- Rotating the device
- Clicking on a button that appears only in landscape mode that will rotate the screen back to portrait.
The problem: The button that puts the screen back to portrait works just fine but then I want to be able to rotate the device to landscape and rotate the screen, but it remains locked in portrait.
The behaviour is like youtube player, where you rotate or click the button to exit fullscreen.
My code for the button:
findViewById(R.id.exit_fs).setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
setRequestedOrientation(Build.VERSION.SDK_INT < 9 ?
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT :
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
}
});
Any ideas?