views:

101

answers:

1

I have a screen layout that is forced to be potrait mode. Because it is very complex I don't have the time right now to invest creating a separate one for landscape mode. It also doesn't make much sense for my type of application.

However, for input fields it's better to provide a landscape mode, because some phones have a hardware keyboard, which automatically aligns the phone in landscape and therefor makes it hard to look at the app that is still in portrait mode.

My solution to this is to put all text input into a dialog and temporarily enable landscape mode (if requested by the user) until the dialog is dismissed again.

This works perfectly. Except of the overlaying search widget (when pressing the search button from my application). I'm looking for two callbacks: one, when the search widget is raised (I cannot listen to the search button, because I sometimes raise it manually via a soft button) and when it is dismissed again (regardless if the search was finally triggered or canceled - it needs to work for both cases).

Any suggestions?

+1  A: 

I'm looking for two callbacks: one, when the search widget is raised (I cannot listen to the search button, because I sometimes raise it manually via a soft button) and when it is dismissed again (regardless if the search was finally triggered or canceled - it needs to work for both cases).

These are onPause() and onResume() in your activity, respectively. Obviously, you will need to use a boolean flag or something to distinguish between being paused for the dialog versus being paused for other reasons, and so on.

CommonsWare
The problem is the onPause() and onResume() callbacks are not triggered when the search widget (the bar at the top to enter the search query) are raised.
znq
Oops, sorry. I am not aware of any callback when the search widget is raised.
CommonsWare