Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Tilt sample app

The tilt demo sample application demonstrates how to limit the screen orientations that a BlackBerry device application supports, how to show and hide the keyboard that appears on the screen, and how to implement a custom Field class so that it reacts to changes in the BlackBerry device orientation.

File name

Description

TitltDemo.java

  • contains the entry point for the application
  • contains the TiltDemo() constructor, which checks if the sample application is running on a BlackBerry device with a touch screen
  • contains the implementation for the listener for the UI components

CustomSpanField.java

extends the Field class to demonstrate how to manage the changing Screen dimensions that occur when the orientation of the BlackBerry device changes

This sample features the following classes:

net.rim.device.api.ui.Touchscreen

The Touchscreen class provides access to the touch screen on a BlackBerry device with a touch screen. The class provides the method isSupported() which returns true if the BlackBerry device that is running the application has a touch screen.

The sample application uses this class to check if the BlackBerry device has a touch screen. If the BlackBerry device does not have a touch screen, the sample application displays a dialog box with the message "This application requires a touch screen device" and closes.

net.rim.device.api.ui.VirtualKeyboard

The VirtualKeyboard class provides methods to access, show, and hide the keyboard that appears on the screen of a BlackBerry device with a touch screen.

The sample application uses this class to toggle the visibility of the keyboard that appears on the screen.

net.rim.device.api.ui.UiEngineInstance

The UiEngineInstance class provides the setAcceptableDirections() method that you can use to set the screen orientations that the application supports. To retrieve an instance of this class for your application, you must use the Ui.getUiEngineInstance() method. The sample application uses this method to set the screen orientations that the sample application supports.

Install the sample app

Visit www.blackberry.com/go/tiltsampleapp to download the sample application.

Extract the tiltdemo.zip file.

On the taskbar, click Start > Programs > Research In Motion > BlackBerry JDE 4.7.0 > JDE.

Open the workspace that you want to add the sample application to.

In the workspace tree, right-click the project that you want to add the sample application to.

Click Add project to <workspace directory>.

In the Add project to <workspace> dialog box, browse to the folder where you extracted the sample application.

Click the tiltdemo.jdp file.

Click Open.

The sample app is also available in github.

Run the sample app

In the workspace where you added the tiltdemo project, right-click tiltdemo.

Click Build project.

On the taskbar, click Start > Applications > Research in Motion > BlackBerry JDE 4.7.0 > Device Simulator.

On the Home screen of the BlackBerry Smartphone Simulator, click the Downloads folder.

Click the Tilt Demo icon.

To simulate tilting the BlackBerry device in the BlackBerry Smartphone Simulator, on the Simulate menu, click Tilt BlackBerry. Click an orientation.