Welcome!

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

Reply
New Developer
rickysiu
Posts: 10
Registered: ‎09-19-2008
My Device: Not Specified

Detect pressing Volume Up / Down Key

Dear Sir/Madam,

  How can I detect pressing Volume Up/Down Key?

  I have tried to capture it by KeyDown event of MainScreen. It does not work. (i.e. not dialog pop up. for other key like escape, camera, make call, end call, they are working)

 

 //Inside MainScreen

    public boolean keyDown(int keycode, int time) {
        Dialog.alert("Key Down ="+ keycode);
        return super.keyDown(keycode, time);
    }

 

Thanks.

Please use plain text.
Developer
richard_puckett
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: Detect pressing Volume Up / Down Key

You want keyControl for those.
Please use plain text.
New Developer
rickysiu
Posts: 10
Registered: ‎09-19-2008
My Device: Not Specified

Re: Detect pressing Volume Up / Down Key

Thanks, richard_puckett. It is working!

 

BTW, I can only use KeyChar to detect Characters.ESCAPE but cannot use KeyControl.

 

However, for Characters.CONTROL_VOLUME_UP, I cannot use KeyControl.

 

Do you know what the reason it?

 

Many Thanks.

Please use plain text.
BlackBerry Employee
BlackBerry Employee
Ro
Posts: 2
Registered: ‎09-11-2008
My Device: Not Specified

Re: Detect pressing Volume Up / Down Key

Hi rickysiu,

 

Could you post up the code that makes keyControl work? I am playing with getting some functionality off these buttons, but I have no idea how to make it work

 

Thanks 

Please use plain text.
New Developer
rickysiu
Posts: 10
Registered: ‎09-19-2008
My Device: Not Specified

Re: Detect pressing Volume Up / Down Key

protected boolean keyControl(char c, int status, int time){       
        boolean retvalue = false;
        if (c == Characters.CONTROL_VOLUME_UP){       
            // do something
            return true;
        } else if (c == Characters.CONTROL_VOLUME_DOWN){           
            // do something
            return true;
        } else {           
            retvalue = super.keyControl(c, status, time);
        }       
        return retvalue;
    } 
Please use plain text.
BlackBerry Employee
BlackBerry Employee
Ro
Posts: 2
Registered: ‎09-11-2008
My Device: Not Specified

Re: Detect pressing Volume Up / Down Key

Thank you...

 

 public class Example1 extends FlowFieldManager

 

My issue is with the actual body of code I should be extending FlowFieldManager? or Manager? (Sorry I am very new, I can research on how to do this - I didn't mean to highjack your thread with my own questions)

 


Please use plain text.