My MIDlet needs to be able to open some web pages for the user. On other J2ME devices this works fine. On BlackBerry (simulator 4.0.2), the code gets:
RuntimeException: pushModalScreen called by non-event thread
I wrote a little test MIDlet that works fine, but my real MIDlet, which does have a few explicit threads, fails with this exception, even if I try to force the thread with UI code immediately preceding the call, as in:
Display.getDisplay( midlet ).setCurrent( new Form("open browser") );
boolean mustExit = midlet.platformRequest( url );
I've seen lots of references to how to do this with a RIMlet, as in
How To - Manage UI interactions
Article Number: DB-00134
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...and
How to - Update a screen on the Main Event Thread
Article Number: DB-00136
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800256/...but not much for MIDlets. The forum thread:
IllegalStateEx: UI engine accesed without hoding the event lock in LocalDevice.getLocalDevice()
http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=220#M220has BlackBerry advice that says "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..." but this seems clearly not to be the case, since I'm getting the above exception and have purely MIDP code. The stack trace:
UiEngineImpl.pushModalScreen(Screen) 481 // line throwing RuntimeException
Dialog.doModal() 509
Dialog.ask(int,String,int) 432
MIDlet.platformRequest(String) 323
... my code
How does one reliably call MIDlet.platformRequest()?