March 1, 2021
Hot Topics:

Screen Rotation in Qualcomm Brew

  • By Ray Rischpater
  • Send Email »
  • More Articles »

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:

Click here for a larger image.

Figure 1: Setting privileges in the MIF file.

Of course, don't forget to document this privilege in your NSTL Specification when you go to submit your application!

Determining Screen Orientation

You'll need to determine screen orientation any time the screen rotates, as well as when your application launches. You do this by using a call to ISHELL_GetDeviceInfoEx:

int iValue = 0;
int iSize = sizeof(iValue);

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

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:


      STRCPY(szBuffer, "r:90");
      p->eCurrScrOrientation = SCREEN_ORIENTATION_LANDSCAPE;
      // Do any other stuff to indicate we're in landscape mode
      // here.

      STRCPY(szBuffer, "r:0");
      pThis->eCurrScrOrientation = SCREEN_ORIENTATION_PORTRAIT;
      // Do any other stuff to indicate we're in portrait mode
      // here.

nError = IDISPLAY_SetPrefs(p->a.m_pIDisplay, szBuffer,

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?

Page 1 of 2

This article was originally published on March 10, 2008

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date