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

Web and WebWorks Development

Reply
Trusted Contributor
Posts: 227
Registered: ‎09-03-2010
My Device: Not Specified
Accepted Solution

popupscreen extention problema

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
	}

}

 


Contributor
Posts: 41
Registered: ‎07-21-2011
My Device: Superberry
My Carrier: Rogers

Re: popupscreen extention problema

[ Edited ]

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:

 

http://supportforums.blackberry.com/t5/Java-Development/updating-UI-from-system-thread-ui-engine-acc...

----------------------------------------------------------------------------------------------
I kode for cudos! Or was it the other way around?
Trusted Contributor
Posts: 227
Registered: ‎09-03-2010
My Device: Not Specified

Re: popupscreen extention problema

Thanks friend was very helpful.