07-21-2011 01:27 PM
Hello everyone.
I'm trying to open a java popupscreen from an extention, and is showing me the following error, tell me I'm doing wrong or if there is an example.
java.lang.IllegalStateException: UI engine accessed without holding the event lock.
package samplecode;
import net.rim.device.api.script.ScriptableFunction;
import net.rim.device.api.system.Alert;
import net.rim.device.api.ui.UiApplication;
public final class AlertFunction extends ScriptableFunction {
public Object invoke(Object obj, Object[] args) throws Exception {
if (!Alert.isVibrateSupported()) {
return UNDEFINED;
}
if (args.length == 1) {
int duration = ((Integer)args[0]).intValue();
Alert.startVibrate(duration);
box vbox = new box();
UiApplication.getUiApplication().pushScreen(vbox);
//UiApplication.getUiApplication().popScreen(vbox) ;
}
return UNDEFINED;
}
}
package samplecode; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.component.ButtonField; import net.rim.device.api.ui.component.LabelField; import net.rim.device.api.ui.container.PopupScreen; import net.rim.device.api.ui.container.VerticalFieldManager; public class box extends PopupScreen { /** * */ public box() { super(new VerticalFieldManager()); LabelField labelField = new LabelField("Popup Screen", Field.FIELD_HCENTER); add(labelField); ButtonField btnfldOk = new ButtonField("OK", ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER); btnfldOk.setMinimalWidth(100); add(btnfldOk); ButtonField btnfldCancel = new ButtonField("Cancel", ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER); add(btnfldCancel); // TODO Auto-generated constructor stub } }
Solved! Go to Solution.
07-21-2011 02:37 PM - edited 07-21-2011 02:38 PM
Hi chicoxml,
This line is your problem:
UiApplication.getUiApplication().pushScreen(vbox);
The issue and the solution is described very well in this thread. Check it out, and let me know if it solved it for you:
07-22-2011 12:02 AM
Thanks friend was very helpful.