So I manually set the orientation in the onCreate to portrait in my app:
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
but I want to change (force) the layout back to landscape when I exit the application. Currently, if my device is locked in landscape and it changes to portrait mode when the app is started I want to be able to go back to landscape. And also vice versa, on onResume I want it to go back to portrait. Is there any way to do this?
EDIT: here is where I try to manually set the orientation back to landscape when I exit the application, but the orientation does not change. When I boot the kernel image its default is landscape orientation but when I change the orientation within an app, the orientation sets it globally on application menu and home screen.
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putInt("Position", myVideoView.getCurrentPosition());
myVideoView.pause();
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
position = savedInstanceState.getInt("Position");
myVideoView.seekTo(position);
}
@Override
public void onDestroy() {
super.onDestroy();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Log.d(CLASS_NAME, "-- ON DESTROY --");
}
@Override
public void onPause() {
super.onPause();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Log.d(CLASS_NAME, "-- ON PAUSE --");
}
@Override
public void onStop() {
super.onStop();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Log.d(CLASS_NAME, "-- ON STOP --");
}