User interface

Send Menu API

You can use the Send Menu API to add a Send menu item to the menu of your application. The Send menu item allows you to send content from your application to a recipient by using another application on the BlackBerry® device, such as the Messages application or BlackBerry® Messenger. The content to send is encapsulated in a JSONObject object that is passed from your application to the application that sends the content from the device.

When a BlackBerry device user clicks the Send menu item, a submenu is displayed with a list of applications that can be used to send the content. When the user clicks one of these applications, the selected application starts with certain fields populated automatically with the content to send. The user can complete the remaining fields and send the content.

Command framework enhancements

You can now unregister commands that your application registered previously with the Command Framework API by invoking unregisterCommand(), unregisterCommandCategory(), or unregisterModuleCommands(). These methods are located in the LocalCommandRegistrarConnection class, which is included in the net.rim.device.api.command package.

For more information about the Command Framework API, see the UI & Navigation Development Guide for the BlackBerry® Java® SDK.

Layering UI elements

You can use the ComponentCanvas class that is included in the net.rim.device.api.ui.container package to place UI components on top of other UI elements on the screen of a BlackBerry device. Unlike AbsoluteFieldManager, which provides similar functionality, a ComponentCanvas is drawn on top of other fields and managers on a screen, like a video or camera field.

You can add any standard UI components, such as labels, buttons, and drop-down lists, to a ComponentCanvas, and these UI components are drawn on top of other UI elements. For example, you can use a ComponentCanvas to display a series of buttons on top of a video field or camera field.

Scan an image for data

You can use the ImageScanner class, provided in the package, to scan and decode data from a frame captured by the device's camera.

When you create a new instance of ImageScanner, you pass the constructor both an implementation of the ImageDecoder and the ImageDecoderListener interface.

The ImageDecoderListener interface provides a method, imageDecoded(), which is invoked when the ImageDecoder is finished parsing the image.

Scan an image for barcode data

The ZXing 1.6 barcode scanning library is now supported in the package. The net.rim.device.api.barcodelib package now provides helper classes for barcode scanning.

You can use the BarcodeScanner class to scan and decode 1D- or 2D-barcode data from a frame captured by the device's camera. When you create a new instance of BarcodeScanner, you pass the constructor an instance of a BarcodeDecoder class and an implementation of the BarcodeDecoderListener or ImageDecoderListener interface.

The BarcodeDecoder interface provides an overloaded method, decode(), which parses data from an image object passed in as a byte array or Bitmap object. It calls a method, BarcodeDecoder.crop() to reduce the number of pixels which need to be parsed, speeding up the process.

The BarcodeDecoderListener interface provides a method, barcodeDecoded(), which is invoked when the BarcodeDecoder is finished parsing the image.

Layer a barcode scanner on top of a viewfinder

You can layer a barcode scanner on top of a viewfinder using the BarcodeScannerOverlay class found in the net.rim.device.api.barcodelib package. In addition, the class contains several constants which allow you to customize elements, such as the border color and point color of a BarcodeScannerOverlay object.

Layer objects on top of a viewfinder

You can layer an object on top of a viewfinder using the ImageScannerOverlay class found in the package. Constructing a ImageScannerOverlay class returns a ComponentCanvas object that you can overlay UI components onto. You can also overlay a ImageScannerOverlay.OverlayField object onto a viewfinder, allowing you to draw graphics on top of a viewfinder using the Field.paint(Graphics) method.

Retrieve the bitmap's luminance source

You can use the BitmapLuminanceSource and PlanarYUVLuminanceSource classes, provided in the net.rim.device.api.barcodelib package, to create objects that represent the grayscale profile of a bitmap object, or planar YUV data object (where the Y channel comes first).

Lightweight Font object

The FontSpec class, provided in the net.rim.device.ui package represents a lightweight Font object containing basic Font attributes such as font family, size and style. It is currently used in OpenVG™ API methods (vgtDrawText(), for example). You can get the FontSpec object representing a Font by using the Font.getFontSpec() method.

Determine the supported color quality

You can determine the color quality that a BlackBerry device supports by invoking DeviceCapability.getDisplayColorQuality(), which is provided in the net.rim.device.api.system.capability package. This method returns a TRUE_COLOR constant if the device supports 32-bit color, and returns a HIGH_QUALITY constant otherwise, indicating that a device supports 16-bit color.

Create 32-bit color bitmaps

You can use the Bitmap.createAlpha() method on a Bitmap object to add an alpha transparency channel to the object. Using createAlpha() will automatically select the most suitable bitmap format.

Retrieve the bitmap type for a given image frame's alpha channel

You can use the new getAlphaType() method provided by the net.rim.device.api.system.EncodedImage class to retrieve the bitmap type for the given frame's alpha channel.

Draw gradient rectangles

You can use the Graphics class in the net.rim.device.api.ui package to draw rectangles with a gradient fill in your application. The gradient fill varies the color within the rectangle continuously based on position, creating a smooth color transition. You can invoke drawGradientFilledRect() to draw a gradient rectangle with sharp corners, and you can invoke drawGradientFilledRoundedRect() to draw a gradient rectangle with rounded corners.

Previous topic: New in this release

Was this information helpful? Send us your comments.