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
Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

How to disable the Call button and call end button.

i have a alarm applicatin which runs in the background for certain interval  ammount of time. When the alrm raises i want only then trackball to work and call recieve and call end button to disable.so that i can access the cancel or snooze buttons of alrm through the track ball.
Developer
bikas
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

Try with registering a KeyListener and handle your Green/Red button event from there.

Handle your button event inside keyDown() method.

 

Somthing like:

protected boolean keyDown(int keycode, int time) { //keycode for green button if (keycode == 1114112) { return true; } ////keycode for red button else if (keycode == 1179648) { return true; } else { return super.keyDown(keycode, time); } }

 

Regards

Bikas

Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

ok Thank Bikas.......Well can u pls provide me the same Key Codes to the BackButton( Button Present Right to the TrackBall) and Button Present Left to Track Ball i am using a BlackBerry 8300 Mobile....kindly Help in This Regards..
Developer
bikas
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

[ Edited ]

Kecode for the backbutton(button right to trackball) -> 1769472

keycode for the menubutton(button left to trackball) -> 268566528

 

Regards

Bikas

Message Edited by bikas on 09-26-2009 06:26 PM
Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

Ok Bikas Thank u again...well as i told u that application is an alarm applicaiton so i need to disable the keys when alarm raises for which  u have giuded me well again when i click cancel in the alarm from TrackBall i need to again enable these Buttons (i.e the Green/red and Right and Left Button beside the Tarack Ball ) how to enable them after disabling them....
Developer
bikas
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

You can do it by using simple flag.

When alarm starts make the flag true and after cancelling the alarm change back the flag false.

 

Something like:

//initially false //when alarm starts make this true //when alarm cancels make this false again private boolean alarmStarted = false; protected boolean keyDown(int keycode, int time) { //keycode for green button if (keycode == 1114112 || keycode == 1179648 || keycode == 1769472 || keycode == 268566528) { if (alarmStarted == true) { //do nothing return true; } else return super.keyDown(keycode, time); } else { return super.keyDown(keycode, time); } }

 

Regards

Bikas


 

Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

Hi Bikas as u told Earlier to registering a KeyListener  I can handle the using the below code rite kindly help if its wrong

 

public static class TheKeyListener implements KeyListener { public TheKeyListener() { System.out.println("\n\n\nAdded key listener.\n\n\n"); }

 

Developer
bikas
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

Just a rough idea. You can try something like below:

 

import net.rim.device.api.ui.component.LabelField; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.system.KeyListener; class TestScreen extends MainScreen implements KeyListener { //used for indicating alarm status //when alarm starts make this true //when alarm cancels make this false again private boolean alarmStarted = false; TestScreen() { this.add(new LabelField("Test Screen")); alarmStarted = false; } public boolean keyStatus(int keycode, int time) { return false; } public boolean keyRepeat(int keycode, int time) { return false; } public boolean keyUp(int keycode, int time) { return false; } public boolean keyDown(int keycode, int time) { if (keycode == 1114112 || keycode == 1179648 || keycode == 1769472 || keycode == 268566528) { if(alarmStarted == true) { //do nothing return true; } else { return super.keyDown(keycode, time); } } else return super.keyDown(keycode, time); } public boolean keyChar(char key, int status, int time) { return super.keyChar(key,status, time); } }

 

Regards

Bikas

 

Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

Hi Bikas i Tried the Above Code to disable the Green/red button when the alarm raises but its not working when i click on the green/red button its in active statue its not diabled and the alrm popup is going backgound with out any responce kindly help in this regrds the green/rd button should not work when alarm raises.
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to disable the Call button and call end button.

[ Edited ]

The code bikas has given you actually implements a KeyListener, but doesn't actually make it active, in other words, the Listener is not listening to anything.

 

In your Screen's constructor, you need something like

 

this.addKeyListener(this);

 

Try this, and then set break points in your listening code (like in keyDown) to demonstrate that it is actually being invoked.

 

That said, I'm not sure you can actually disable these keys in the way suggested.  I've never done it and they do seem to have some special affinity to the processing.  I'd like to know how you get on with this. 

 

Edit ignore this post, Screen and MainScreen already have keyListener implemented.....  Apologies

Message Edited by peter_strange on 09-29-2009 11:34 AM