In my app I have a custom AlertDialog (handled by the system using showDialog()) which contains a tabhost with 2 tabs. In one of the tabs is a spinner. I can rotate my scr
I had a similar a crash. I worked around by disabling orientation changes when dialog is displayed.
@Override
public void onDismiss(DialogInterface dialog) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
@Override
public void onShow(DialogInterface dialog) {
int loadedOrientation = getResources().getConfiguration().orientation;
int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
if (loadedOrientation == Configuration.ORIENTATION_LANDSCAPE) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
} else if (loadedOrientation == Configuration.ORIENTATION_PORTRAIT) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
setRequestedOrientation(requestedOrientation);
}
NOTE: I actually found that there is no reliable way to lock screen orientation.