I am having a media player application built using LWUIT. My problem is that I am unable to increase/decrease the volume of the media player when the user presses any volume hardware key of the device. Please help.
2 Answers
Create an app with a plain Canvas
and run it on your device. On the canvas's keyPressed
function, print the results out to the screen. I suspect nothing will happen when you press the volume keys, in which case you have no way of doing anything when these keys are pressed.

- 8,432
- 6
- 39
- 52
-
Thanks funkybro for your reply. I have checked that no events are caught when we press volume keys. In such a case, we have no other way to rectify it. – Shafi Nov 21 '11 at 14:43
For some devices you just don't get an event and for others you will get wildly differing values as funkybro has stated. You can do the same experiment with a LWUIT application (no need for canvas).
Android does expose volume keys but I would recommend avoiding them and letting it handle its own volume since its such a complicated subject on Android. The RIM implementation in LWUIT has a static listener which you can bind to volume key events but this will only work on RIM devices.

- 51,749
- 5
- 35
- 65
-
Thanks shai for your response. As you stated, can i get a list of devices which support these events along with those values because i am developing only for some specific phones. May be i can identify the family of devices which support these events, or i can handle them differently for all using preprocessors. I am able to map volume keys for blackberry using RIM's keylistener, but am unable to find something similar for J2ME devices. – Shafi Nov 21 '11 at 14:41
-
We don't maintain such a list since the effort required would be impractical to maintain such a list. – Shai Almog Nov 24 '11 at 09:26