Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

What is the Device Capability API?

by Retired on ‎08-15-2011 09:11 AM - edited on ‎08-15-2011 09:43 AM by Retired (1,363 Views)

In BlackBerry® 6.0 we introduced a new Device Capability API:




This API is designed to allow you to query or listen for changes in the status of various capabilities of a BlackBerry device, such as the whether it has a virtual keyboard or whether the display can rotate. It is also designed to be future proof, so you can use it to check for capabilities that do not exist in BlackBerry  6.0 by passing in the value of their constant.


There are several states a capability can be in:


Supported - A capability that is "Supported" is one that a device has the ability to do in general. Whether a device can rotate or not is dependant on the presence of the hardware acceleratorometor, and unlikely to change. The "Supported" state should be something that stayes the same in the long term.

Allowed - A capability that is "Allowed" is one that the device should let you use at the time. For example, on a device with a physical keyboard ready to use, the virtual keyboard would not be allowed. You could still use it (check if it's supported), but it's not recommended. This state is likely to change frequently, so you will definitely want to check it every time you want to use it.


Avaliable - A capability that is "Avaliable" is one that is ready to use at the moment. If the virtual keyboard is currently displayed, it would be avaliable. This can change very frequently, so it should be checked every time you need it.


To find out what state a capability is in, you can either use the isSupported, isAllowed and isAvaliable methods to query the current status, or register a DeviceCapabilityListener to be notifed when a certain capability changes.


This API is designed to be forward compatible. All of the base methods take a long parameter to specify the capability they are referring to. For example:




What this does is let you check for capabilities that are supported in the future while still compiling for BlackBerry 6.0 just by passing in the value new constant.


There are also a set of convenience methods you can use so you do not have to use the constant if you are checking for capabilites that exist in the OS you are compiling for.




This would give you the same answer as the previous block of code. The listeners work the same way.


For a working example of this API in action, please see the attached sample.


Note: There is an issue with tis API when using BlackBerry® 6.  This has been resolved in BlackBerry® 7.

Users Online
Currently online: 45 members 697 guests
Please welcome our newest community members: