07-16-2008 06:59 AM - edited 07-16-2008 07:11 AM
I do get IllegalStateExeption: UI engine accesed without hoding the event lock, when I call LocalDevice.getLocalDevice(). In code below do get following list: 1, 2, 3, 4, Exception: java.lang.IllegalStateExeption: UI engine accesed without hoding the event lock.
Interestingly, but this code was working yesterday.
What does this exception means and how to solve this problem?
The device is 8820 4.2.2.160 version. BlackBerry JDE is 4.2.1.
Thanks!
try { testList = new List("Testing", List.EXCLUSIVE); testList.append("1", null); testList.setCommandListener(this); testList.append("2", null); testList.addCommand(Commands.CMD_EXIT); testList.append("3", null); display.setCurrent(testList); testList.append("4", null); try { local = LocalDevice.getLocalDevice(); testList.append("5", null); agent = local.getDiscoveryAgent(); testList.append("6", null); agent.startInquiry(DiscoveryAgent.GIAC, this); testList.append("7", null); } catch (BluetoothStateException ex) { testList.append("Problem in searching the Bluetooth devices", null); testList.append("Exception: " + ex.toString(), null); } } catch (Exception ex) { testList.append("Exception: " + ex.toString(), null); }
Solved! Go to Solution.
07-16-2008 03:28 PM
Are you certain that it's the call to LocalDevice.getLocalDevice() that's the source of the error? I.e. if you attach the debugger or to your app or you throw in print statements, is that definitely the line of code that results in this exception?
Typically, this exception indicates that you are updating the UI from a non event thread. Moreover, in the MIDP UI space, you should be more or less immune to this sort of consideration, since the concept of an event thread doesn't necessarily apply to MIDP (unless of course you're mixing MIDP UI with BlackBerry UiApplication functionality). As a workaround, you could try wrapping your UI update calls in invokeLater(), but more importantly, we'll need to identify the source of this error being thrown assuming that you're operating in a pure MIDP setup.
More information on the event thread can be found here:
07-17-2008 03:18 AM
My application is pure MIDP. We already had application for HP iPAQ that we are porting to BB. And now we are trying bluetooth connection with barcode reader. I did not used debugger. I have used printing in TextBox after every code line, and printing stops after LocalDevice.getLocalDevice()
Now I do call LocalDevice.getLocalDevice() method from new thread, and it seems to work O.K.:
(new Thread() {
public void run() {
try {
myDevice = LocalDevice.getLocalDevice();
} catch (BluetoothStateException ex) {
testBox.insert("Exception u run(): " + ex + "\n", testBox.size());
}
}
}).start();
02-19-2009 07:37 AM
02-24-2009 09:33 AM
What BlackBerry handheld software version are you testing on? You can find this under Options, About on the BlackBerry Smartphone. Are you able to reproduce this in version 4.5.0? Can you provide a code snippet that is triggering the exception and note the line that is throwing the exception.