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

Capture volume keys in a MIDlet

by Retired ‎02-16-2010 03:01 PM - edited ‎09-16-2010 03:26 PM (1,624 Views)



This article applies to the following:


  • BlackBerry® smartphones based on Java® technology with BlackBerry® Device Software 4.3 and later


When a BlackBerry smartphone user presses the Volume keys, only the current application will process a volume change; the volume settings are not global across BlackBerry smartphone applications, including third-party applications. For example, if a BlackBerry smartphone user increases the volume in the Phone application, the volume in the Media application will not change unless the Volume keys are pressed while the Media application is in the foreground. This fine level of control allows for maximum flexibility but puts the responsibility on the implementing application to process Volume key actions.


Prior to BlackBerry Device Software 4.3, only applications built using the BlackBerry smartphone user interface (UI) APIs could capture events triggered by the Volume keys. This limitation was due to the Mobile Information Device Profile (MIDP) specification not defining a constant that could be mapped to the Volume keys. However, MIDP does allow the implementing BlackBerry smartphone application to define negative (i.e. less than 0) constant values while still adhering to the specification. Leveraging this flexibility, on a BlackBerry smartphone with BlackBerry Device Software 4.3 or later, a MIDP application may override the Canvas.keyPressed(int keyCode)method to detect a Volume key event. The values that map to the Volume keys are listed in the following table:

BlackBerry Smartphone key  keyCode 
Volume Up -150
Volume Down -151
on ‎08-22-2013 10:05 PM

When I got my Z10, this was one of my worries, not being able to capture screenshots of what was being displayed on my screen, because it is something I use frequently and I looked hard and long to find an application with this feature, while it was sitting there, (About Two Weeks) just waiting for me to pounce

Users Online
Currently online: 22 members 1,754 guests
Please welcome our newest community members: