View Single Post
Old 04-03-2010, 04:46 PM   #2 (permalink)
jacob.tabak
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   Reply With Quote