How do I handle screen orientation changes when a dialog is open?
<p>I have an android app which is already handling changes for orientation, i.e. there is a <code>android:configChanges="orientation"</code> in the manifest and an <code>onConfigurationChange()</code> handler in the activity that switches to the appropriate layout and preps it. I have a landscape / portrait version of the layout.</p>

<p>The problem I face is that the activity has a dialog which could be open when the user rotates the device orientation. I also have a landscape / portrait version of the dialog.</p>

<p>Should I go about changing the layout of the dialog on the fly or perhaps locking the activity's rotation until the user dismisses the dialog. </p>

<p>The latter option of locking the app appeals to me since it saves having to do anything special in the dialog. I am supposing that I might disable the orientation when a dialog opens, such as </p>

<pre><code>setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
</code></pre>

<p>and then when it dismisses</p>

<pre><code>setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
</code></pre>

<p>Would that be a sensible thing to do? If the screen orientation did change while it was locked, would it immediately sense the orientation change when it was unlocked?</p>

<p>Are there alternatives?</p>
