I don't know the answer to your question, but here's what I'd try.
First, the simplest thing. I think you might be able to use the
Activity's setRequestedOrientation function and set it to whatever
orientation you want it to stay in. So when the ProgressDialog is
started:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
When it returns, assuming you want the device's default behavior:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
I'm not sure if
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) will
block orientation changes after it is issued. It might just change the
orientation once, but the ActivityInfo parameters seem to suggest
otherwise.
If that doesn't do the trick, then I'd get more complex. First, set
the Activity's android:configChanges="orientation" in the
AndroidManifest.xml, then implement onConfigurationChanged in the
Activity's class. Something like:
void onConfigurationChanged(Configuration newConfig) {
if (!priorityDialogIsShowing) {
switch(newConfig.orientation) {
case Configuration.ORIENTATION_PORTRAIT:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case Configuration.ORIENTATION_PORTRAIT:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
default:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
break;
}
}
}
Anyway, I'm not an expert, that's just what I would try.
On Apr 15, 3:44 am, Kumar Bibek <[email protected]> wrote:
> Hi,
> Well, preventing an orientation change is easy. But what about doing
> it at run time.
>
> Say, I have an activity which supports orientation change in normal
> situations. It has say three Edit Texts.
>
> There's also a button, which when clicked would do some processing in
> a thread while showing a ProgressDialog which is not cancellable.
>
> Ok, so till the user hits the Button, I want the activity to be able
> to adapt the orientation changes. I have two layouts files for each
> orientation with different layout schemes.
>
> What I want is this. Once the user clicks on the button, and the
> ProgressDialog is showing, I don't want the activity now to be re-
> created again when the orientation changes. So, before showing the
> ProgressDialog, is there any way to tell the Activity not to handle
> Orientation change?
>
> Also, once the process is complete, and the ProgressDialog is removed,
> I want the Activity again to be able to handle orientation changes.
>
> :) I know, we can save the state of all the things, and retrieve them
> back. But, just curious if this can be done?
>
> Thanks and Regards,
> Kumar Bibek
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe, reply using "remove me" as the subject.