Screen Rotation in Qualcomm Brew

An increasing number of new phones sport rotating screens, with BREW applications able to run whether the screen is in portrait or landscape orientation. Recent versions of Qualcomm BREW provide an alerting mechanism to let you know when the user has rotated the screen, as well as a way to determine the current screen orientation. By using this information and a bit of dynamic layout trickery, you can add dynamic rotation support to your application. In this article, I show you how to determine the current screen orientation and listen for events indicating screen rotation changes.

Setting the Privileges Necessary to Determine Screen Orientation

By default, not all applications are permitted to determine the screen orientation. BREW defines a specific privilege, AEEPRIVID_DISPLAYSETTINGS (0x01030810), that your application must assert before attempting to determine screen orientation. You do this in your application's MIF, in the Dependencies section, as you see in Figure 1:

AEE_DEVICESTATE_SCR_ORIENTATION returns either SCREEN_ORIENTATION_LANDSCAPE or SCREEN_ORIENTATION_PORTRAIT, and is a guideline as to how the screen should be oriented. It's up to you to tell the display at what orientation it should actually draw text and controls. This changes how BREW draws into a screen's bitmap.

Setting Screen Orientation

Related Articles

To set how BREW will draw into the screen's bitmap, you need to use IDISPLAY_SetPrefs. This interface takes a string indicating the options BREW should apply when writing to the device bitmap, including:

r:number: Rotate the screen number degrees: typically either '0' or '90'.

w:number: Set the screen width to number.

h:number: Set the screen height to number.

a:number: Show the annunciators (number=1) or hide the annunciators (number=0).

You concatenate the values into a string, and pass the string to IDISPLAY_SetPrefs. So, for example, you might write something like this:

Being Notified of Screen Rotation

You need to test to determine the desired screen orientation at two different places in your application: at startup (to determine how you should lay out your user interface), and whenever the user rotates the screen. But just how do you know when that happens?