BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-03-2010, 01:23 PM   #1 (permalink)
New Member
 
Join Date: Dec 2009
Model: 9530
PIN: N/A
Carrier: Verizon Wireless
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default IllegalArgumentException on PopScreen

Please Login to Remove!

Hi Everyone,

When I try to close a Screen, I am receiving an IllegalStateException.

What I have noticed, however, is that when I push this screen and then close out of it (pop), it works fine. However, if I push the screen, click on one of the buttons on my screen, and then close out of the screen, I receive the IllegalStateException. This is even true if I click on a button that does not have a fieldchangelistener associated with it.

Here is my stack trace:

Code:
Thread [KFlicks(228)id=319047680] (Suspended (exception IllegalStateException))	
	Search2Screen(Screen).close() line: 579	
	Search2Screen(Screen).onClose() line: 3700	
	Search2Screen(Screen).keyCharUnhandled(char, int, int) line: 3017	
	Search2Screen(MainScreen).keyCharUnhandled(char, int, int) line: 320	
	Search2Screen(Screen).dispatchKeyEvent(IKeyEvent) line: 697	
	Search2Screen(Screen).processKeyEvent(IKeyEvent) line: 3422	
	UiEngineImpl.processMessage(Object, Message, boolean) line: 3587	
	Application(Application).doProcessNextMessage(Message) line: 2252	
	Application(Application).processNextMessage(Message) line: 1516	
	Application(Application).enterEventDispatcher() line: 1357	
	Application.main(String[]) line: 28
On "Search2Screen(Screen).close() line: 579", UIEngine = Null

Can anyone offer me any help? Thanks!

Last edited by behrk2 : 04-03-2010 at 01:34 PM.
Offline  
Old 04-03-2010, 03:46 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The subject of your post says illegal argument exception and the body of your post says illegal state exception. I'm going to assume your problem is illegal state exception. You will encounter this exception a lot you're not familiar with the concept of the event thread.

This article explains it pretty well: BlackBerry UI Threading - The Very Basics - Thinking BlackBerry

Basically, when you launch your application, you probably use the UiApplication.enterEventDispatcher() method. Whichever thread this method is called on becomes the event thread, and it is the only thread that is allowed to directly modify the UI of your application.

If you attempt to modify the UI from a different thread, you'll receive an illegal state exception.

The way to overcome this problem is to use the following technique:
Code:
UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() { 
        //your UI code here 
    }
});
I typed that from memory so there may be syntax errors, but look at the examples on thinkingblackberry.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.