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
Contributor
Posts: 10
Registered: ‎08-11-2009
My Device: Not Specified

Problem with custom component trackwheelClick() and keyChar()

I have a Blackberry application that is running on the 8310, OS 4.5.0.55 platform 2.7.0.68 and developed using blackberry API 4.2

 

I am having some problems with a custom component. The customer is reporting that a certain piece of the functionality that uses this component stops working after a while.

 

The functionality consists of a screen with several of these custom components which can be selected. When a item is selected the handleSelection() method is called which either requests some data from the server or displays a screen. 

 

They are reporting that for some users after a period of time, selecting the component has no effect.  They have also said that the period of time varies from user to user and that the problem does occur frequently.  The component is made up of a CheckboxField and LabelField and is shown below

 

public class CustomSelectionButtonField extends Manager {

private LabelField label;
private CheckboxField checkBox;

public CustomSelectionButtonField(String label) {
super(USE_ALL_WIDTH);

this.checkBox = new CheckboxField() {
// Not focusable so the user can never edit it.
public boolean isFocusable() {
return false;
}

// Editable so that it is not greyed out.
public boolean isEditable() {
return true;
}

};
add(this.checkBox);

this.label = new LabelField(label) {
private int timeLastPressed;

public boolean isFocusable() {
return true;
}

protected boolean keyChar(char character, int status, int time) {
if (character == (char) Keypad.KEY_ENTER || character == (char) Keypad.KEY_SPACE) {
if (time - timeLastPressed > 500) {
timeLastPressed = time;
handleSelection();
}
} else {
return false;
}
return true;
};

protected boolean trackwheelClick(int status, int time) {
if (time - timeLastPressed > 500) {
timeLastPressed = time;
handleSelection();
}
return true;
}
};
add(this.label);
}

///Rest of code excluded
}

 

The customer has provided us with a log file from a device that the problem has occurred on. From insepecting it we can see that the handleSelection() method is not being called (there is a message logged as soon as the method is called. This is not present)

 

So the problem appears that for certain users, after a period of time, the handleSelection() method stops being called. The only way I can see this happening is if somehow the time value passed in is incorrect.

 

I think the use of the time value is not really needed and I would like to remove it but I want to be able understand what is causing the problem first before doing that.

 

We have tried to recreate the problem but have been unsuccessful

 

Does anybody know of any circumstances whereby the time passed into  trackwheelClick() or keyChar() is incorrect?

 

Would this be something that could be possibly be effected by a setting in the IT policy or software configuration?

 

Is there any other possible explanation as to why this method would not be getting called?

Thanks in advance.

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Problem with custom component trackwheelClick() and keyChar()

"time" is the number of ms since the device was last restarted.

 

Since the time variable is an int, it will go negative after about 24 days, right?

 

This might be causing your issue.

 

Why not just use the System.currentTimeMills() ??  (a long value)

 

Contributor
Posts: 10
Registered: ‎08-11-2009
My Device: Not Specified

Re: Problem with custom component trackwheelClick() and keyChar()

I had thought that as well but the customer has reported as problem as

 

1) inital error happening

2) the user pulling out the battery

3) restarting the application and the problem occuring again straight away

 

that would seem to rule that out. It is a possiblity that the bug has been reported incorrectly.  I am hoping to remove the check for time altogether. I just want to know that is what is causing the problem and its not something else. 

 

 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Problem with custom component trackwheelClick() and keyChar()

[ Edited ]

Have you actually tried the code on a working device? I would use your own global variables to handle time using System.getTimeMillis() to make sure that the time value is in milliseconds and not seconds.

 

Also, you say that you method requests data from a server. Do you spawn another thread to do this, because keyChar and navigationClick are running on the Ui thread and if not, then you are blocking it from processing any more actions which could cause it to stop working.

Contributor
Posts: 10
Registered: ‎08-11-2009
My Device: Not Specified

Re: Problem with custom component trackwheelClick() and keyChar()

I have tried it on an acutal device and I can't reproduce the issue. We do spawn a seperate thread for the request to the server and we output some logging before doing this. In the example log file we have been given there was evidence of the log lines so it does not seem to be reaching that part of the code.

We are going to contact the customer to double check the intial bug report. I just wanted to check there was not any other factors that could be causing this.

 

Thanks for the responses.

Contributor
Posts: 10
Registered: ‎08-11-2009
My Device: Not Specified

Re: Problem with custom component trackwheelClick() and keyChar()

I have checked with the customer and they are insisting that this problem is present  on devices that have been switched on for less than 24 days. Does anyone know of anything else that could effect the value for time that is passed to the trackwheelClick() method?

 

Just to reiterate, I will be removing the code that uses this value for the next release but I want to be sure that is what is causing the problem.